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

I tried running npm install -g angular-cli

enter image description here

I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also. enter image description here


Solution 1:

You can also try:

 > npm run ng <command>

Solution 2:

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.

Open up the Terminal on macOS/Linux or Command Prompt on Windows and run the following command to find out the version of Node you are running:

node --version

Solution 3:

I had the same issue on Windows7. I resolved it setting correct path.

  1. First find ng.cmd file on your System. It will usually at:

    E:\Users\<USERNAME>\AppData\Roaming\npm
    
  2. Set PATH to this location.

  3. Close existing command window and open new one

  4. Type

    ng version
    

Also remember to install angular with -g command.

npm install -g @angular/cli

Solution 4:

You should not add C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng to your PATH. There is only a javascript file which you cannot use in terminal.

You need ng.cmd which is probably located at %AppData%\Roaming\npm. Make sure this path is included in your PATH variable.