The ng not recognized error means Windows can’t find Angular CLI’s ng.cmd through your PATH.
You run ng to start a project, generate a component, or check versions. Then the terminal tells you it isn’t a command. That message feels vague, yet it points to a simple fact: your shell searched for a file named ng (or ng.cmd) and didn’t see it in any folder listed in PATH.
Below, you’ll confirm what’s missing, fix it on Windows, and learn a clean fallback that runs Angular CLI without a global install. You’ll also avoid the common trap of adding the wrong folder to PATH and ending up with more confusion.
It’s a setup snag, not a broken Angular project.
On shared PCs, check user and system PATH entries. A tool installed for a different login won’t show in your shell until you add that bin folder.
What The Error Means In Plain Terms
Every time you type a command, Windows checks the current folder, then checks each folder listed in PATH. If none of those folders contains a matching executable, you get the “not recognized” message.
Angular CLI installs a small launcher file for Windows called ng.cmd. That file usually lives in npm’s global “bin” folder. If that folder isn’t on PATH, Windows won’t see ng.cmd, even if Angular CLI is installed.
When people hit this, the cause is usually one of these:
- Missing Angular CLI Install —
@angular/cliwas never installed on the machine. - Missing Npm Global Bin In PATH — The install exists, yet the folder that holds
ng.cmdisn’t listed inPATH. - Old Shell Session — You changed
PATHor installed the CLI, yet the terminal window you’re using still has old values loaded. - Conflicting Node Installs — A version manager, an old Node folder, or a changed npm prefix sends global installs to a different place than your shell expects.
Fast Checks Before You Change Anything
These checks take two minutes and keep you from guessing. Run them in the same terminal where you saw the error.
- Confirm Node Works — Run
node -v. If it fails, install or repair Node first. - Confirm Npm Works — Run
npm -v. If it fails, Node is installed incorrectly or your terminal can’t see npm. - See If Windows Can Locate Ng — Run
where ngin Command Prompt. If it prints a path tong.cmd, the CLI is present and your issue is often just a shell refresh. - Check Where Global Tools Install — Run
npm config get prefix. On Windows, global command files usually land in that prefix folder. - Confirm Angular CLI Is Installed — Run
npm list -g @angular/cli. If it shows nothing, you don’t have a global CLI install. - Restart The Terminal — Close the terminal app, reopen it, then try
ng versionagain.
One extra check can save time when npm’s folders are unclear. Run npm root -g to see where global packages live, and run npm prefix -g to see where command files should land. If those two paths don’t line up with what you see in a folder window, fix prefix first, then reinstall Angular CLI.
If you saw ng is not recognized as an internal or external command, keep going. The next sections walk you through the two fixes that solve nearly every case.
Ng Is Not Recognized As An Internal Or External Command
On Windows, the most common fix is simple: make sure the npm global bin folder that contains ng.cmd is listed in PATH. Do this once and the command works in any new terminal session.
Find The Folder That Holds Ng.cmd
Don’t guess the path. Find the exact folder on your machine so you add the right entry the first time.
- Check The Npm Prefix — Run
npm config get prefixand copy the path it prints. - Check The Usual Windows Bin Folder — Open a folder window and paste
%AppData%\npminto the location bar. - Confirm With Where — Run
where ng. If Angular CLI is installed and reachable, you should see a path ending inng.cmd.
Add The Correct Folder To PATH
Once you know the correct folder, add it to PATH so every new terminal can find it.
- Open System Properties — Press
Win, type “Edit the system variables,” then open it. - Open Variables Window — Click “Variables,” then select
Pathunder your user section, then click “Edit.” - Add The Npm Bin Folder — Click “New” and add the folder that contains
ng.cmd, often%AppData%\npm. - Save And Refresh — Click OK on all dialogs, close terminals, then reopen them.
After that, run ng version. If it works, you’re done with the core fix. If it still fails, don’t keep stacking random paths. Switch to a clean install so you remove conflicts instead of piling on workarounds.
Clean Install That Avoids Conflicts
If you’ve installed Node more than once, used a version manager in the past, or changed npm’s prefix at some point, a clean install can be faster than chasing a single bad entry. The goal is one Node install, one npm, one predictable global bin folder.
Remove Old Pieces That Cause Clashes
- Uninstall Node — Use Windows “Apps & features” to remove Node.js, then reboot.
- Clear Old Global Shims — Visit
%AppData%\npmand remove oldng*files if you see them and you’re sure they’re stale. - Check For Multiple Node Locations — Search your drive for
node.exe. If you see multiple copies in different folders, keep one install path and remove the rest.
Install Fresh, Then Recheck PATH
- Install Node LTS — Install the current LTS build from the official Node site, then reboot once.
- Confirm Versions — Run
node -vandnpm -vto confirm they launch cleanly. - Install Angular CLI — Run
npm install -g @angular/cli. - Verify The Launcher File — Run
where ngand confirm it points tong.cmdin a single folder.
If the install succeeds but the command still fails, it almost always means the bin folder isn’t on PATH, or the shell didn’t reload variables yet. Close terminals, reopen them, then try again before you change anything else.
Run Angular CLI Without A Global Install
Some people avoid global installs on purpose. It keeps machine setup smaller, and it prevents one project from stepping on another. You can still run Angular CLI through npx, which comes with npm.
Create A Project With Npx
- Pick A Working Folder —
cdinto the folder where you want the project created. - Run The One-Time CLI — Use
npx -p @angular/cli ng new my-appand follow the prompts. - Run Common Commands — Inside the project folder, run
npx ng serve,npx ng build, ornpx ng test.
Why Npx Sidesteps The Problem
- No Global Bin Needed — You’re invoking the CLI through
npx, so Windows doesn’t need to findng.cmdglobally. - Project-Level Version Control — You can pin a specific CLI version by running
npx -p @angular/cli@17 ng versionwhen you need it. - Less Drift Over Time — You avoid global tool updates changing behavior across older projects.
If you mainly want to ship and don’t want to touch system settings, npx is a clean workaround that still keeps you in the normal Angular workflow.
Ng Not Recognized After Install Fix Checks
If the standard fixes didn’t stick, something on the machine is still steering installs or command lookup in an unexpected direction. The checks below target the cases that waste the most time.
Command Works In One Shell But Not Another
- Test In Command Prompt — Run
where ngandng versionin Command Prompt first. - Compare Shell Behavior — If you also use PowerShell, run the same commands there and compare results.
- Confirm You’re Running The Same Tool — If PowerShell reports a different path, you’re not launching the same
ng.cmdfile.
Global Installs Land In A Strange Folder
- Read The Prefix — Run
npm config get prefixand note the path. - Reset Prefix If Needed — If that prefix points to a locked folder or an old drive, reset it back to a normal user path.
- Reinstall After The Reset — Run
npm uninstall -g @angular/cli, thennpm install -g @angular/cli.
Npm Is Present But Acts Broken
- Repair Node Install — Rerun the Node installer and use its Repair option if it appears.
- Check Cache Folder Access — Verify
%AppData%\npm-cacheexists and your user account can write to it. - Try A Fresh Terminal — Close terminals, reopen, then rerun
npm -vandnpm install -g @angular/cli.
Quick Reference Table
| Symptom You See | What It Means | Fast Fix |
|---|---|---|
where ng returns nothing |
CLI missing or bin folder not on PATH |
Install @angular/cli, then add %AppData%\npm to PATH |
where ng shows a path, yet ng fails |
Old shell session still loaded | Close terminals, reopen, then retry ng version |
| Command Prompt works, PowerShell fails | PowerShell script rules block a launcher | Run via Command Prompt, then adjust PowerShell rules if needed |
| Global installs appear under an unexpected drive | Npm prefix changed | Reset prefix, reinstall CLI, then recheck with where ng |
When It Works In One App But Not In Another
It’s common to fix PATH, test in Command Prompt, then open an editor terminal and still hit the same error. That doesn’t mean the fix failed. Many apps read user variables only at launch, so they keep an old snapshot until you restart them.
- Restart The Editor — Close it, reopen it, then run
where nginside its terminal. - Check Shell Profile Files — If you use Git Bash or a custom shell, confirm it isn’t overriding
PATHinside a profile script. - Test The Same Command In Two Places — Run
where ngin Command Prompt and in the app terminal. If the outputs differ, the app is still on old settings.
Also watch for a naming clash. If a folder in your project contains a file named ng, some shells try that first. Running where ng keeps you honest because it shows what the shell will actually execute.
A Simple Routine To Confirm You’re Done
- Check Versions — Run
node -v,npm -v, thenng version. - Confirm The Path — Run
where ngand verify it points to a single, expected folder. - Test A Real Command — Run
ng new test-appornpx ng new test-appto confirm the tool chain works end to end. - Keep One Install Style — Stick with global CLI plus
PATH, or stick withnpx. Mixing styles across shells is what brings the error back.
If you ever see ng is not recognized as an internal or external command again, use this two-step check before you touch anything else: run npm config get prefix, then confirm that folder contains ng.cmd and is listed in PATH. That’s the quickest way to get from error to working command with minimal fuss.
