Skip to content
Latchkey

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.

nuxt
sh: 1: nuxt: not found
npm ERR! code 127
npm ERR! command failed
npm ERR! command sh -c nuxt build

Common 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

  1. Run npm ci so nuxt is installed from the lockfile.
  2. Run nuxt prepare to generate the .nuxt directory.
  3. Run the build or generate command.
Terminal
npm ci
npx nuxt prepare
npx nuxt build

Keep postinstall enabled

Do not pass --ignore-scripts in CI, or run nuxt prepare explicitly so generated files exist.

package.json
{
  "scripts": { "postinstall": "nuxt prepare" }
}

How to prevent it

  • Use npm ci so nuxt is always installed.
  • Avoid --ignore-scripts, or run nuxt prepare manually.
  • Keep the postinstall: nuxt prepare script in place.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →