Nuxt V4 npm run preview error can't find module "E:\WebDev\My-App\.output\.output\"

Hello, i upgraded my project to nuxt v4 but update the update this error occur. the console log show like this:
ℹ Loading .env. This will not be loaded when running the server in production.
ℹ Starting preview command: node .output/server/index.mjs
node:internal/modules/cjs/loader:1404
throw err;
^

Error: Cannot find module 'E:\WebDev\My-App\.output\.output\server\index.mjs'
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
at node:internal/main/run_main_module:36:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v22.17.1

ERROR Process exited with non-zero status (1)
ℹ Loading .env. This will not be loaded when running the server in production.
ℹ Starting preview command: node .output/server/index.mjs
node:internal/modules/cjs/loader:1404
throw err;
^

Error: Cannot find module 'E:\WebDev\My-App\.output\.output\server\index.mjs'
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
at node:internal/main/run_main_module:36:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v22.17.1

ERROR Process exited with non-zero status (1)
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @CrunchyNuts. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you’re seeing:
Error: Cannot find module 'E:\WebDev\My-App\.output\.output\server\index.mjs'
Error: Cannot find module 'E:\WebDev\My-App\.output\.output\server\index.mjs'
suggests that Nuxt is trying to start the preview server from a path that includes .output\.output\server\index.mjs, which is incorrect. The correct path should be .output/server/index.mjs. This kind of issue can happen if the build output is not generated correctly, or if there’s a misconfiguration causing the preview command to look in the wrong directory. Here are some possible causes and troubleshooting steps based on the knowledge sources: 1. Check Your Build Output
Make sure you have run npm run build before running npm run preview. The .output directory should contain a server/index.mjs file after a successful build. If .output is empty or missing files, the preview command will fail with this error. This issue has been reported before, and sometimes starting with a fresh Nuxt project and carefully copying your files over can resolve mysterious build issues if the output is not being generated as expected Nuxt3 build .output folder remains empty, nothing copied from .nuxt. 2. Check for Misconfiguration
Double-check your package.json scripts and any custom configuration in nuxt.config.ts that might affect the build or output directory. The default build and preview scripts should look like this:
"scripts": {
"build": "nuxt build",
"preview": "nuxt preview"
}

"scripts": {
"build": "nuxt build",
"preview": "nuxt preview"
}

The .output directory should not be nested inside another .output directory. 3. Clean Up and Rebuild
Delete the .output and .nuxt directories, then run:
npm run build
npm run preview

npm run build
npm run preview

This ensures there are no stale files causing path issues. 4. Check for Path Issues
If you have customized the output directory or are using Windows, ensure there are no path concatenation mistakes in your configuration or scripts that could result in .output\.output. 5. Node Version Compatibility
While not directly referenced in the sources, using a very new Node.js version (like v22) could potentially cause issues if Nuxt or its dependencies are not fully compatible yet. If possible, try with an LTS version (e.g., Node 20) to rule out version-specific problems. If after these steps the problem persists, and especially if .output/server/index.mjs is not being generated, consider initializing a fresh Nuxt project and migrating your code, as this has resolved similar issues for others Nuxt3 build .output folder remains empty, nothing copied from .nuxt. If you need to run the server manually, the correct command (after a successful build) is:
node .output/server/index.mjs
node .output/server/index.mjs
as also referenced in the official docs for preview and deployment nuxt preview. Summary:
- Ensure you run npm run build before npm run preview. - The .output directory should contain server/index.mjs. - Clean up old build artifacts and check for misconfigurations. - If the issue persists, try migrating your code to a fresh Nuxt project. If you need more specific help, please provide your package.json scripts and any custom configuration related to build/output paths. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@766145789068050432> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Flamenate
Flamenate2mo ago
GitHub
Build fail · Issue #32667 · nuxt/nuxt
Environment After executing the &quot;yarn create nuxt&quot; command, it was confirmed that the version of nuxt &quot;4.0.0&quot; was installed. It works fine in dev mode without any problems. I ha...

Did you find this page helpful?