vue-email / nuxt

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

Cannot find email template after `nuxt build` #13

Closed vosamoilenko closed 10 months ago

vosamoilenko commented 10 months ago

Environment

Package deps

Issue description

The vue-email/nuxt works great when I'm running pnpm dev. As soon I do pnpm build && pnpm start I see the error in console:

Error loading component node:internal/modules/cjs/loader:573
      throw e;
      ^

Error: Cannot find module '/Users/vo1/Developer/vue-email-repro-missing-component/vue-email-repro-missing-component/.output/server/node_modules/vue-email/dist/index.cjs'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1098:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1091:15)
    at resolveExports (node:internal/modules/cjs/loader:567:14)
    at Module._findPath (node:internal/modules/cjs/loader:636:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at /Users/vo1/Developer/vue-email-repro-missing-component/vue-email-repro-missing-component/.output/server/node_modules/import-string/dist/wlflv5w9v8m5WT2r6LTqd.js:36:24
    at Script.runInContext (node:vm:135:12) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/vo1/Developer/vue-email-repro-missing-component/vue-email-repro-missing-component/.output/server/node_modules/vue-email/package.json'
}
[nuxt] [request error] [unhandled] [500] Error rendering template Test: Error: Component Test not found
  at templateRender (./server/node_modules/@vue-email/compiler/dist/index.mjs:57013:11)  
  at async useCompiler (./server/chunks/generate.post.mjs:27:20)  
  at async ./server/chunks/generate.post.mjs:39:20  
  at async Object.handler (./server/chunks/nitro/node-server.mjs:2203:19)  
  at async toNodeHandle (./server/chunks/nitro/node-server.mjs:2392:7)  
  at async ufetch (./server/chunks/nitro/node-server.mjs:2758:17)  
  at async $fetchRaw2 (./server/chunks/nitro/node-server.mjs:2630:26)  
  at async $fetch2 (./server/chunks/nitro/node-server.mjs:2672:15)  
  at async setup (./server/chunks/app/server.mjs:810:19)

Minimal repo is attached for repro. vue-email-repro-missing-component.zip

adrienZ commented 10 months ago

I have the same error on this stackblitz: https://stackblitz.com/edit/github-usvs6j?file=nuxt.config.ts

/api/email

Flowko commented 10 months ago

if you can both upgrade to 0.8.8 , clean node_modules and lock files please

@vosamoilenko please use stackblitz for code, i wont download that file, also @adrienZ it should resolve the component issue, but also i noticed that you are importing vue-email components in the test.vue file, you shouldnt do that, the components of the library are auto imported, also, you will face another issue with the baseUrl you should only use the base Url if you gonna use it for images

https://stackblitz.com/edit/github-usvs6j-5oeyxy?file=package.json,emails%2Ftest.vue,nuxt.config.ts

i updated the base url and update the img src, will open another issue related to this speciifc image issue

adrienZ commented 10 months ago

if you can both upgrade to 0.8.8 , clean node_modules and lock files please

@vosamoilenko please use stackblitz for code, i wont download that file, also @adrienZ it should resolve the component issue, but also i noticed that you are importing vue-email components in the test.vue file, you shouldnt do that, the components of the library are auto imported, also, you will face another issue with the baseUrl you should only use the base Url if you gonna use it for images

https://stackblitz.com/edit/github-usvs6j-5oeyxy?file=package.json,emails%2Ftest.vue,nuxt.config.ts

i updated the base url and update the img src, will open another issue related to this speciifc image issue

upgrading and removing imports from vue-email fixed it, thanks @Flowko !

eBrou commented 10 months ago

@Flowko Hi. First, thank you for your work on this module!

I'm looking into a similar issue and it has not been solved by upgrading to 0.8.8. I'm also seeing that the stackblitz linked above still has the same error, even with the updated version. (If that link isn't adequate I can look into creating a separate stackblitz soon)

Could you please advise? Thanks in advance