Nuxt 3 deployment fails at start with 'Cannot find module' for an @/ alias — which log phase to trust
0 reputation · 16 Oct 2021, 01:35 UTC
A Nuxt 3 (v3.4+) app builds cleanly with nuxt build, but the deployed server exits during startup with an error resembling Cannot find module '@/utils/config'. The build log shows no warning, so the failure only surfaces when Nitro actually runs the server bundle.
The suspicion is that @/ aliases are resolved for client-side code by Vite, while server-side files bundled by Nitro only resolve them if the alias is declared in nuxt.config.ts or tsconfig.json — and that this behavior depends on whether a src directory exists. The deployment target is a Node server preset, and the output directory is the default .output.
The uncertainty is diagnostic rather than configurational: since the build phase reports success, it is unclear which stage of the log (build output, Nitro prerender, or the node .output/server/index.mjs runtime) is the authoritative place to confirm a missing server-side alias before redeploying.
Questions:
- Is it expected and documented that a missing server-side alias produces no build-time warning in Nuxt 3, only a runtime module-not-found error?
- Does the presence or absence of a
srcdirectory change Nitro's automatic alias resolution, and where is this behavior specified? - What is the most reliable local reproduction — build plus running
.output/server/index.mjs— to confirm the log signature matches the deployment failure?