5

NodeJS version: v10.0.0

npm version: 5.6.0

After I did 'npm install -g @angular/cli' it was successfully installed

But when I try to run the 'ng' command: 'ng' is not recognized as internal or external command

4

6 Answers 6

9

In some cases works only with this command, try it.

npm run ng
2
  • I got an error message: 'npm ERR! missing script: ng'
    – user10541187
    Commented Jan 17, 2019 at 17:35
  • Maybe angular isn't installed globally, you have runed npm i -g @angular/cli before? Commented Jan 22, 2021 at 19:40
4

Please check if you have ng command prompt file in your npm system environment path:

For example, if your system npm path user environment variable is - C:\Users\priyanka\AppData\Roaming\npm, make sure the ng command prompt file is present in the specified path.

If the path for npm is not present, kindly add the above specified path into the path variable.

Once done kindly restart app and re run the above ng command.

Hope this helps!

0
2

On Windows: Check if the npm path "C:\Users\user\AppData\Roaming\npm" is on the Path variable on Environment Variables of windows.

Check if the file ng.cmd is on this folder C:\Users\user\AppData\Roaming\npm.

If not, run the command npm install -g @angular/cli and test again.

0

Use following command in cmd to create folder locally "npx new [foldername]" in the required directory

0

Try to repair your nodejs installation by reinstalling it and choose the repair option.

1
  • Welcome to Stack Overflow _ Unfortunately this isn't an answer to the problem in the question as much as it's a suggestion (which should really be a comment below the question post) _ And, as you can see from the comments below the question, the solution has already been found _ When you have earned enough SO reputation you will be allowed to comment under questions _ In the meantime please take a moment to visit SO Help Center to learn how questions are asked and answered >>> stackoverflow.com/help Commented Oct 19, 2019 at 0:27
0

What you can do is : (1) Set the Path variable under System Variable to "C:\Users\user\AppData\Roaming\npm"

(2) now try to hit below commands in new CMD : ng -v or ng version

because in my case ng version is giving the output.