Skip to content
Latchkey

Angular "ng: command not found" - Fix in CI

The CI shell could not find ng. The Angular CLI is not in this job's node_modules, a production-only install skipped it, or the script assumes a global install the runner does not have.

What this error means

The step exits 127 with ng: command not found.

node
sh: 1: ng: command not found
npm ERR! code 127
npm ERR! command failed

Common causes

CLI not in dependencies

@angular/cli is not installed locally, or --omit=dev pruned it.

Script relies on global ng

The script calls bare ng instead of the local binary in node_modules/.bin.

How to fix it

Use the local CLI via npm scripts

  1. Install @angular/cli as a dev dependency.
  2. Call build through npm scripts so ng resolves from node_modules.
Terminal / package.json
npm install -D @angular/cli
# package.json
"build": "ng build"

Run via npx if no script

  1. Invoke the locally installed CLI directly.
Terminal
npx ng build --configuration production

How to prevent it

  • Always invoke ng through npm scripts or npx, never a global install.
  • Keep dev dependencies installed for build jobs.

Frequently asked questions

What causes "ng not found"?
@angular/cli is not installed locally, or --omit=dev pruned it.
How do I fix ng not found?
Use the local CLI via npm scripts

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card