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:
3 Replies
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:
suggests that Nuxt is trying to start the preview server from a path that includes
Make sure you have run
Double-check your
Delete the
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
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
- Ensure you run
.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 OutputMake 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 MisconfigurationDouble-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:
The .output
directory should not be nested inside another .output
directory.
3. Clean Up and RebuildDelete the
.output
and .nuxt
directories, then run:
This ensures there are no stale files causing path issues.
4. Check for Path IssuesIf 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 CompatibilityWhile 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:
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:
----------------------<@766145789068050432> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
GitHub
Build fail · Issue #32667 · nuxt/nuxt
Environment After executing the "yarn create nuxt" command, it was confirmed that the version of nuxt "4.0.0" was installed. It works fine in dev mode without any problems. I ha...