Nuxt "Cannot find module nuxt" / "nuxt: command not found" in CI
The CI step invokes nuxt or imports the nuxt module and Node cannot find it. Either dependencies were not installed cleanly, or nuxt prepare did not generate the .nuxt types the build expects.
What this error means
A build or generate step fails with "nuxt: command not found" or "Error: Cannot find module 'nuxt'". The same command works on a developer machine.
sh: 1: nuxt: not found
npm ERR! code 127
npm ERR! command failed
npm ERR! command sh -c nuxt buildCommon causes
Dependencies were not installed
A missing or skipped install leaves nuxt out of node_modules, so the binary and module are absent.
nuxt prepare did not run
The postinstall: nuxt prepare step that generates .nuxt was skipped (for example with --ignore-scripts), leaving the project unprepared.
How to fix it
Install cleanly and prepare
- Run
npm cisonuxtis installed from the lockfile. - Run
nuxt prepareto generate the.nuxtdirectory. - Run the build or generate command.
npm ci
npx nuxt prepare
npx nuxt buildKeep postinstall enabled
Do not pass --ignore-scripts in CI, or run nuxt prepare explicitly so generated files exist.
{
"scripts": { "postinstall": "nuxt prepare" }
}How to prevent it
- Use
npm cisonuxtis always installed. - Avoid
--ignore-scripts, or runnuxt preparemanually. - Keep the
postinstall: nuxt preparescript in place.