Nuxt with PM2 and TypeScript
I have a project with a Nuxt application and PM2. For the PM2 application we have a file named worker.cjs. I turned this into a TypeScript file, so that I can leverage the types we have from our Supabase database. I am trying to have it compiled when Nuxt builds, so I've added an extra tsconfig as composite. Does somebody have experience with this?
2 Replies
Hi @Skyleos. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, I don't have enough specific information to fully address your question about compiling a PM2 worker file with TypeScript alongside a Nuxt application. The knowledge sources don't contain information about integrating PM2 workers or compiling external TypeScript files as part of the Nuxt build process.
However, I can provide some general information about TypeScript configuration in Nuxt that might be helpful:
1. Nuxt automatically generates a
.nuxt/tsconfig.json
file with sensible defaults and your aliases. You can extend this in your project's root tsconfig.json
file:
Docs > Guide > Directory-structure > tsconfig.json (https://nuxt.com/docs/guide/directory-structure/tsconfig)
2. You can extend the generated TypeScript configuration using the tsConfig
option in your nuxt.config.ts
file:
Docs > Api > Nuxt Configuration > typescript > tsConfig
(https://nuxt.com/docs/api/nuxt-config#tsconfig)
3. For type-checking at build time, you can use the typescript.typeCheck
option:
Docs > Guide > Concepts > TypeScript (https://nuxt.com/docs/guide/concepts/typescript)
Regarding your specific error, it seems that the Nuxt TypeScript configuration is trying to include your worker file, but it hasn't been compiled. You might need to adjust your TypeScript configuration or build process to handle this external file separately from the Nuxt build.
Unfortunately, the provided knowledge sources don't contain information about integrating PM2 workers or compiling external TypeScript files as part of the Nuxt build process. You might need to look into separate TypeScript compilation for your worker file or explore Nuxt modules that could help with this specific use case.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@245519377066229760> Kapa.ai is still learning and improving, please let me know how I did by reacting below.