Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

The terminal says 'ng: command not found' after installing Angular

Errorng: command not found

Short answer

The shell finds ng only if the Angular CLI is installed and npm's global bin folder is on your PATH. Check where npm links global commands, compare it with PATH, and either add that folder or install the CLI again. Inside a project you can also skip the global install and run npx ng.

  • Applies to Angular CLI 19, Node.js 22, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask npm where global commands are linked, then check that this folder is in PATH. On Unix, executables go to the bin folder under that prefix; on Windows they go straight into the prefix.

    npm config get prefix
    echo $PATH | tr ':' '\n'
    npm ls -g --depth=0
  2. 2Match what you see, then jump to its fix

    1. 1npm ls -g does not list @angular/cliThe Angular CLI was never installed globallyFix
    2. 2npm ls -g lists @angular/cli, yet the shell still says command not foundnpm's global bin folder is not on PATHFix
    3. 3ng works in one terminal or after one nvm use, and disappears in anotherThe install went to a different Node.js than the one your terminal usesFix

What does the error look like?

  • ng: command not found
  • zsh: command not found: ng
  • 'ng' is not recognized as an internal or external command, operable program or batch file.

Cause 1 of 3

The Angular CLI was never installed globally

1Check

The package is installed per project by default. A project copy puts ng in node_modules/.bin, not on your PATH.

npm ls -g --depth=0 | grep angular

2Fix

Install the CLI globally, using Node.js at the version the Angular docs list as supported.

npm install -g @angular/cli

3Verify

Open a new terminal and print the version.

ng version

Confirmed by angular.dev

Did this fix it?

Cause 2 of 3

npm's global bin folder is not on PATH

1Check

Global executables are linked into the prefix's bin folder on Unix. If that folder is missing from the PATH output, the shell cannot see ng.

ls "$(npm config get prefix)/bin" | grep ng

2Fix

Add the folder to PATH in the startup file your shell actually reads, then reload it.

# example for zsh; use your own shell's startup file
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

3Verify

The command resolves to a path inside the prefix.

which ng

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

The install went to a different Node.js than the one your terminal uses

1Check

Each Node.js installation has its own global prefix, so a global package follows the Node.js version that installed it.

which node
npm config get prefix

2Fix

Stay on one Node.js installation, then reinstall the CLI under it.

npm install -g @angular/cli

3Verify

ng and node come from the same prefix.

which node
which ng

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Change npm's prefix to a folder in your home directory once, so global installs do not need sudo and the PATH line is permanent.
  • Inside a project, run ng through npm scripts or npx so the project's own CLI version is used.
  • Open a new terminal after changing PATH; an old window keeps its old environment.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.