nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 628 forks source link

Nuxt content 2.6.0 produces 500 ERR_MODULE_NOT_FOUND on production build #2037

Open supermar1010 opened 1 year ago

supermar1010 commented 1 year ago

Environment

Reproduction

Try to build the nuxt project with yarn build

Describe the bug

Starting the project fails with:

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/.output/server/node_modules/unstorage/drivers/overlay.mjs' imported from /.output/server/index.mjs
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:326:11)
    at moduleResolve (node:internal/modules/esm/resolve:945:10)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Additional context

Works fine in deve env, but fails when building for production

Logs

No response

farnabaz commented 1 year ago

Did you try to remove lock file and clean install? This is related to deps conflict in lock file

ThomasFindlay commented 1 year ago

I'm running into the same issue. A clean reinstall doesn't help and I tried with different package managers.

ThomasFindlay commented 1 year ago

It started to work after I installed the unstorage package.

hecktarzuli commented 1 year ago

I had this problem today. I nuked my yarn.lock and node_modules and re-installed. Works great.

syblock commented 1 year ago

My code was working in dev mode but it failed to work in production mode. and it was not working because the unstorage module was missing. I installed it but it didn't fix the problem. I ended up to manually copied the module to the output folder. you can add a postinstall script and copy the folder from node_modules to .output/server/node_modules

rm -r .output/server/node_modules/unstorage
cp -r ./node_modules/unstorage .output/server/node_modules/unstorage