-2
'ng' is not recognized as an internal or external command,
operable program or batch file.

So when I run ng serve, the above error shows. I ran npm audit fix --force, but then also the same error is showing.

  • Please search this site for *not recognized as an internal or external command, operable program or batch file*. This question has been asked (and answered) here many times before. A basic search is something that you should do to try to solve the problem yourself before asking here. – Ken White Nov 23 '21 at 05:06
  • 1
    Does this answer your question? [ng is not recognized as an internal or external command](https://stackoverflow.com/questions/37991556/ng-is-not-recognized-as-an-internal-or-external-command) – Kiran Mistry Nov 23 '21 at 05:07
  • No. I saw that question earlier, it was not helpful. – Forever Lost Account Nov 23 '21 at 05:08
  • check node, npm & angular cli exists or not. https://angular.io/guide/setup-local – Pinaki Nov 23 '21 at 05:19
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 26 '21 at 21:50

1 Answers1

3

This error is simply telling you that Angular CLI is either not installed or not added to the PATH. To solve this error, first, make sure you’re running Node 6.9 or higher. A lot of errors can be resolved by simply upgrading your Node to the latest stable version.

The command line for that is

node- v

Or

 node --version

run in cmd

 npm install -g @angular/cli

and then ( open in Windows 10) Go to Settings -> About -> at the right side -> Advance system settings.

Step - 1:

enter image description here

Step - 2: System Properties -> Select Advanced from the menu bar -> Click on the Environment variables

enter image description here

Step- 3: Click on the path and edit

enter image description here

Step - 4: Add missing ng path

C:\Users\PC\AppData\Roaming\npm


C:\Users\PC\AppData\Roaming\npm\node_modules\@angular\cli\bin

enter image description here

Finally, restart all opened command prompts and try again.