NestJS "nest: command not found" (@nestjs/cli) in CI
The shell could not find nest because @nestjs/cli lives in node_modules/.bin, which is only on PATH inside npm scripts. A direct nest build in a raw shell step fails.
What this error means
A step running nest build or nest start fails with "nest: command not found" and exit code 127, even though npm run build works locally.
Node
/home/runner/work/_temp/script.sh: line 1: nest: command not found
Error: Process completed with exit code 127.Common causes
The CLI is a devDependency not installed in CI
A production-only install (npm ci --omit=dev) skips @nestjs/cli, so the nest binary is absent.
Calling nest directly instead of via npm script
A bare nest build in a run step does not have node_modules/.bin on PATH; only npm-run scripts add it automatically.
How to fix it
Run the CLI through an npm script or npx
- Invoke the build via
npm run build, which puts the local bin on PATH. - Or call the CLI with
npx nest buildso the local binary resolves. - Ensure dev dependencies are installed for the build job.
.github/workflows/ci.yml
- run: npm ci
- run: npm run build # runs "nest build" with node_modules/.bin on PATHDo not omit dev dependencies when building
The build needs the CLI, so install the full dependency set in the build job even if the runtime image is production only.
Terminal
npm ci # not "npm ci --omit=dev" for the build stepHow to prevent it
- Always run the CLI through npm scripts or npx, never a bare
nest. - Install dev dependencies in build jobs so the CLI is present.
- Keep build and production installs in separate, clearly named steps.
Related guides
NestJS "Cannot find module '@nestjs/...'" in CIFix NestJS "Error: Cannot find module '@nestjs/common'" in CI - a required @nestjs package is not installed,…
NestJS "nest build" error TS with decorators / emitDecoratorMetadata in CIFix "nest build" TypeScript errors about decorators in CI - tsconfig is missing experimentalDecorators or emi…
NestJS monorepo (apps/libs) build / project not found error in CIFix NestJS monorepo build errors in CI - nest build needs the project name, and library path mappings in tsco…