Fix: ng is not recognized as an internal or external command

You installed the Angular CLI, typed ng version or ng new, and the terminal answered 'ng' is not recognized as an internal or external command, operable program or batch file. In PowerShell the same problem reads The term 'ng' is not recognized as the name of a cmdlet.

The message means your shell cannot find an ng executable in any folder on its PATH. The usual causes are that the Angular CLI was never installed globally, that Node.js is missing, or that the npm global folder is not on PATH (or the terminal was opened before you changed it). The fastest fix is to confirm Node and npm work, run npm install -g @angular/cli, add the folder printed by npm config get prefix to PATH, and open a new terminal. If you only need a one-off command, npx ng works without touching PATH.

Animated diagram: ng fails because no PATH folder contains it, then the npm global folder is added to PATH and ng version works

The animation is an illustration of how the lookup works, not a real screenshot.

Why ‘ng’ is not recognized

  • Angular CLI is not installed globally. Installing it inside a project (without -g) puts it in node_modules/.bin, which is not on PATH.
  • Node.js or npm is not installed, or its folder is missing from PATH.
  • The npm global bin folder is not on PATH. On Windows this is normally the folder printed by npm config get prefix; on macOS and Linux it is the bin folder inside that prefix.
  • The terminal was opened before the install or the PATH change. Already open terminals, including the VS Code integrated terminal, keep the old PATH until restarted.
  • nvm or another version switch. Global packages are installed per Node version, so after switching versions the CLI can disappear.
  • Permissions. A global install that failed with an access error leaves no ng behind.

Step 1: Check Node, npm and the Angular CLI

Run these in a new terminal and note which one fails first:

node -v
npm -v
ng version
npm config get prefix
npm list -g @angular/cli
  • If node -v or npm -v fails, install Node.js from the official Node.js download page (see the version table below), then open a new terminal.
  • If both work but ng version fails, the CLI is missing or its folder is not on PATH; continue with the steps for your system.

The package name is @angular/cli. The old name angular-cli is obsolete, so do not install it.

Step 2: Fix it on Windows

Install the CLI globally, then check where npm puts global commands:

npm install -g @angular/cli
npm config get prefix

With a standard Node.js installer the prefix is usually %AppData%\npm. Windows installs ng.cmd in that folder, so that folder must be on PATH. To add it for your user:

  • Press Start, search for Edit environment variables for your account and open it.
  • Select Path under User variables, choose Edit, then New, and paste the exact folder printed by npm config get prefix.
  • Click OK on every dialog, close all terminals and VS Code, then open a new terminal and run ng version.

If PowerShell then reports that ng.ps1 cannot be loaded because running scripts is disabled, that is a different error caused by the execution policy; see Angular PowerShell ng.ps1 cannot be loaded. Command Prompt is unaffected by it.

Step 3: Fix it on macOS and Linux

The shell prints zsh: command not found: ng or bash: ng: command not found. Install the CLI, then find the global bin folder:

npm install -g @angular/cli
echo "$(npm config get prefix)/bin"
echo $PATH

If the printed folder is not inside $PATH, add it to your shell profile (~/.zshrc on macOS, ~/.bashrc on most Linux systems). Replace the folder below with the one printed on your machine:

export PATH="$(npm config get prefix)/bin:$PATH"
source ~/.zshrc   # or: source ~/.bashrc

If npm install -g fails with EACCES, do not use sudo. Follow npm’s guide to resolve EACCES permission errors: either use a Node version manager or point npm at a folder you own with npm config set prefix, then add that folder’s bin to PATH.

Use npx ng as a workaround

npx ships with npm. It runs a local CLI from node_modules/.bin if one exists, and otherwise downloads @angular/cli temporarily, so it needs no PATH change:

npx @angular/cli version
npx @angular/cli new my-app

# inside an existing project:
npx ng serve

This is useful to unblock yourself or to create a project, but fixing PATH is better for daily work.

Local vs global Angular CLI

A project created with ng new has @angular/cli in its devDependencies. Inside that project, npx ng and npm scripts such as npm start use the local copy, which is why npm start can work while a bare ng does not. The global copy is only the command that creates new projects and forwards to the local one. If the two versions differ, see global Angular CLI version is greater than local and this version of CLI is only compatible with Angular. The Angular local setup guide describes the supported install.

Which Node.js version does your Angular version need?

Angular lists the supported Node.js ranges on its versions reference. At the time of writing (checked against that page):

  • Angular 22: Node.js ^22.22.3, ^24.15.0 or ^26.0.0.
  • Angular 21: Node.js ^20.19.0, ^22.12.0 or ^24.0.0.
  • Angular 20: Node.js ^20.19.0, ^22.12.0 or ^24.0.0.

An unsupported Node version usually produces a different error, but it is worth checking with node -v if the install itself fails. The page changes with each release, so confirm there before upgrading.

Other causes: nvm, permissions and VS Code

  • nvm: global packages belong to one Node version. Run nvm use <version>, then npm install -g @angular/cli again. On Windows this means nvm-windows, a separate project.
  • VS Code terminal: close every VS Code window and reopen it, or open a new terminal tab, so it picks up the new PATH. Check which shell it uses in the terminal dropdown.
  • Several Node installs: run where node (Windows) or which -a node (macOS/Linux) to see which one wins.
  • Corporate machine: if you cannot edit PATH or install globally, use npx or ask your administrator to allow the npm global folder.

More Angular CLI commands and errors are collected in Angular CLI common commands, errors and resolutions.

What was tested

The commands above follow npm and Angular documentation. They were not run in a live Windows, Linux or nvm environment while writing this update, and no Node.js is installed on the machine used to prepare it, so no command output is shown here. Verify each step on your own system with the checks in Step 1. The Node.js ranges were read from the Angular versions page.

Frequently asked questions

Why does ng work in one terminal but not another?

Each terminal reads PATH when it starts. Terminals opened before the install or the PATH change do not see it, and different shells (Command Prompt, PowerShell, Git Bash, VS Code) can use different settings. Open a new terminal and run ng version.

What is the correct package name for the Angular CLI?

It is @angular/cli. Install it with npm install -g @angular/cli. The old angular-cli package is obsolete.

Do I need to install the Angular CLI globally?

No. You can run npx @angular/cli new my-app to create a project and npx ng or npm scripts inside it. A global install only gives you the shorter ng command everywhere.

Summary

‘ng’ is not recognized means the shell cannot find the Angular CLI on PATH. Check node -v, npm -v and npm config get prefix, install @angular/cli globally, add the npm global folder to PATH, and open a new terminal. Use npx ng when you cannot change PATH, and check nvm, permissions and your VS Code terminal if it still fails.

Found this useful?

Bookmark this page and share it with your team. Get new .NET, cloud and database tutorials in your inbox.

17 thoughts on “Fix: ng is not recognized as an internal or external command”

  1. If I will open a differnt user then run ng serve it’s giving me error
    ng’ is not recognized as an internal or external command’

    1. Hello Pankaj- Thanks for your query . Please set the User environment variable for every new user.
      If you set those 2 variable as System environment variable then i think that should works even if you chnage the user.

      1. Did you perform Angular CLI installation for new %USERPROFILE% as well? see if npm install -g @angular/cli@latest commands for new profile works for you.

Leave a Reply

Your email address will not be published. Required fields are marked *