vue-email / nuxt

💚 Official Nuxt module for Vue Email. Build email templates with Vue components.
https://vuemail.net/getting-started/nuxt-nitro
MIT License
108 stars 3 forks source link

Nuxt compiler bug in production #40

Closed HugoRCD closed 1 month ago

HugoRCD commented 4 months ago

I created this issue on the main package, but I think it's more appropriate here

https://github.com/vue-email/vue-email/issues/168

Gugustinette commented 4 months ago

Running into the exact same problem on Vercel Serverless runtime.

I'm getting these 2 errors at the same time when trying to render a template using useCompiler :

Error: Error rendering template ResetPassword: Error: Component ResetPassword not found
    at templateRender (file:///var/task/node_modules/@vue-email/compiler/dist/index.mjs:57021:11)
    at async useCompiler (file:///var/task/chunks/routes/api/auth/ask-reset-password.post.mjs:34:20)
    at async sendEmail (file:///var/task/chunks/routes/api/auth/ask-reset-password.post.mjs:56:22)
    at async Object.handler (file:///var/task/chunks/routes/api/auth/ask-reset-password.post.mjs:100:3)
    at async Object.handler (file:///var/task/chunks/runtime.mjs:2998:19)
    at async toNodeHandle (file:///var/task/chunks/runtime.mjs:3264:7)
    at async Server.<anonymous> (/opt/node-bridge/bridge-server-CNJTFAIF.js:1:9585)
Error loading component Error: The package "esbuild-linux-64" could not be found, and is needed by esbuild.

If you are installing esbuild with npm, make sure that you don't specify the
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
of "package.json" is used by esbuild to install the correct binary executable
for your current platform.
    at generateBinPath (/var/task/node_modules/esbuild/lib/main.js:1819:15)
    at esbuildCommandAndArgs (/var/task/node_modules/esbuild/lib/main.js:1886:33)
    at ensureServiceIsRunning (/var/task/node_modules/esbuild/lib/main.js:2051:25)
    at startSyncServiceWorker (/var/task/node_modules/esbuild/lib/main.js:2261:19)
    at Object.<anonymous> (/var/task/node_modules/esbuild/lib/main.js:2302:3)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)

I guess this has something to do with https://github.com/vue-email/nuxt/blob/a6b685a65e14e43a20b28a00066f8613aa30e63e/src/runtime/server/nitro/useCompiler.ts#L14 , but i'm not quite sure what is useStorage here. Is that the one from Nitro and UnStorage ? From my understanding, this is by default some in-memory key-value storage, which then do not make sense in the context of a serverless function ? But that still won't explain why "esbuild-linux-64" won't be found ? I tried to force install it locally on my project but it still wasn't found in Vercel's serverless context.

eliabieri commented 3 months ago

I'm facing the exact same problem

dcln00 commented 3 months ago

I'm facing the exact same problem as well

dcln00 commented 3 months ago

I had it fixed. Deleted package-lock.json and node modules directory and installed it again fixed it.

Gugustinette commented 3 months ago

Fixed here in theory https://github.com/vue-email/vue-email/issues/168

Flowko commented 1 month ago

we just merged a new project rewrite, please do check the docs and the updated logic https://vuemail.net/