-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt compiler bug in production #168
Comments
Have the same problem but with |
I'm facing the exact same problem |
I'm also facing the exact same problem |
This issue appears to be that the
However the Just investigating how it ends up only pulling over the .mjs file now or perhaps trying to force resolution to be ESModule. |
So I'am |
So in my case this issue was caused by the imports in my email component. It seems you are unable to import vue-email inside here. When removing the vue-email imports e.g. import {
EBody,
EButton,
EColumn,
EContainer,
EHead,
EHeading,
EHtml,
EImg,
EPreview,
ERow,
ESection,
EText,
} from 'vue-email' Then I no longer have this error in production. Hope this helps someone! |
@GerryWilko if you remove the imports, how do get the components? If you can share details about how you were able to solve than can be helpful |
They appear to be auto imported. Looking inside the compile function i noticed that they seemed to be part of the auto imported code. If you check the examples on the Vue-Email site it does show them without the explicit imports. I have a feeling this may be a recent change as I think I took one of the examples and modified it for my own use case and now they seem to have no imports in the examples. Or my IDE was trying to be helpful and added them automatically. To be clear my email templates work fine in the IDE and in production with no imports so they arent needed and so seem to be the source of the error listed in this issue. |
Removing the imports didn't work on my side 😕 Btw I'm on Also, I'm really surprised this could have an impact on the error, as the components not being found are the Vue Mails we are writing, not the components imported inside. |
What worked for me was deleting the node modules directory with package-lock.json file and running npm install again. |
So I digged some of the code : The first async function loadComponent(name: string, source: string, verbose = false) {
try {
name = correctName(name)
const compiledComponent = compile(name, source, verbose)
const componentCode: Component = (await importModule(compiledComponent)).default
return componentCode
}
catch (error) {
console.error('Error loading component', error)
}
return null
} Then the second error appears because the previous function returned const component = await loadComponent(name, code.source, verbose)
if (verbose)
console.warn(`${lightGreen('💌')} ${bold(blue('Generating output'))}`)
if (!component)
throw new Error(`Component ${name} not found`) This seems to be related to the |
Sooo I didn't sleep BUT I FIXED IT. esbuild Source CodeHere is the piece of code from esbuild that crashes when vue is rendering the template. Obviously, it tries to resolve the package dynamically, and it just isn't found in the vercel context. The issueI was digging a lot on how the package couldn't be found, even when we were trying to force install the This is basically because Nuxt won't include it in the built Every serverless function should have the node_modules folder at its root. However, Nitro (which powers Nuxt) compiles to only one serverless function called So The solutionI still don't know how to solve it correctly using Nitro config. {
...
"scripts": {
"build": "nuxt build && cp -r ./node_modules/esbuild-linux-64 ./.vercel/output/functions/__nitro.func/node_modules/esbuild-linux-64",
},
...
} Basically modify your build command to manually copy the missing package from the "build node_modules" to the "serverless node_modules". I'm sure there is a way to just tell Nitro to include the package, but for now I'm too lazy and need to sleep. 🥹 |
I feel like Tailwind doesn't really work with this solution, does it? |
who tf uses Tailwind anyway Joke aside, are you facing the issue even with the fix ? Maybe there's also an error with Tailwind not being included in the node_modules, which would require to also |
Well if I understand it correctly, this module converts tailwind classes to inline styles at some point so I don't know whether it actually needs the tw source or not. Maybe it is missing from the node_modules... When I removed the explicit component imports & used your build copy command the mails do send. It's only the styles that are missing. I'll experiment with it when I have some time |
I try to modify the build command but it still not work |
I get the same error using Netlify. |
Can you provide logs ? I don't know much about Netlify, if you are deploying to a serverless environment, the solution could be similar to Vercel : {
...
"scripts": {
"build": "nuxt build && cp -r ./node_modules/esbuild-linux-64 ./.vercel/output/functions/__nitro.func/node_modules/esbuild-linux-64",
},
...
} (Of course, directories will probably be named differently) |
These are the logs i get from Netlify
|
As far as I know from Netlify, this could be solved with this build command : nuxt build && cp -r ./node_modules/esbuild-linux-64 ./.netlify/functions-internal/server/node_modules/esbuild-linux-64 |
After deploying my project on Vercel, I often encounter this error. Each time, I end up having to redeploy the project to fix it. I was wondering if you might have any insights on what could be causing this issue.
Here is all piece of code related:
resendService.ts
./emails/verify-otp.vue
The text was updated successfully, but these errors were encountered: