2

After removing the previous version of Node.js , now i have installed the latest version of it. I have also installed @angular/cli .

enter image description here

But when i am trying to create new Project through CLI , i am getting error

'ng' is not recognized as an internal or external command.

I have uninstalled Node.js several time using command and manually all folder but still it coming after fresh installation.

I have tried to install @angular/cli but getting below error.

enter image description here

Any help will be much appreciated. Thanks in Advance.

15
  • 1
    did you reinstall the angular with -g argument? Commented Jul 9, 2017 at 11:22
  • how did you install @angular/cli? did you restart the command line after installing it? run the following $ npm list -g --depth=0 , what does it show? Commented Jul 9, 2017 at 11:23
  • Well clearly angular cli is not installed properly if ng is not available. npm install -g @angular/cli On Windows it's best to do that using the powerShell and need to be run as admin and it will work in windows shell too.
    – GillesC
    Commented Jul 9, 2017 at 11:23
  • @AnkitSaroch : You are talking about installing npm install -g @angular/cli command right ? Yes i have done that .
    – semwal
    Commented Jul 9, 2017 at 11:24
  • @Maximus : After running the command it show C:\Users\Naveen\AppData\Roaming\npm `-- (empty)
    – semwal
    Commented Jul 9, 2017 at 11:28

3 Answers 3

2

There are two reasons.

  1. It could be you do not have npm folder on your PATH after installing Angular (npm install @angular/cli -g)

Append the below entry in your system or user environment variable: %USERPROFILE%\AppData\Roaming\npm

Open a new windows shell and ng command should be available.

ng -v

 
   _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.2 Node: 6.9.2 OS: win32 x64 Angular: ...
  1. Your Angular version is corrupted. As of Angular 5 you don't need to clean the cache. It self-heals from corruptions. To check if the cache is corrupted, use

    npm cache verify

For older version of Angular, uninstall using:

npm uninstall -g angular-cli npm uninstall --save-dev angular-cli

To install new version, use:

npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest

Good luck.

0

Simple way to solve this by using NodeJS command prompt rather Windows Command, NodeJs command prompt will recognize ng.

1
  • I have tried with Node.js command prompt but getting same error : npm ERR! request to registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz failed, reason: 0:error:1408F10B:SSL ro utines:SSL3_GET_RECORD:wrong version number:openssl\ssl\s3_pkt.c:365
    – semwal
    Commented Jul 9, 2017 at 12:04
0

I did everything above to no avail. Uninstalled VS2017 and NodeJS. After reinstalling NodeJS and angular cli still had same problem. I did a npm get and noticed it was installed in an old folder "c:\programdata\microsoft\visualstudio\mda\taco-toolset.x.x.x.." which made no sense all VS version were completely gone. It ended up being a file in "c:\users\yourUsername\.npmrc" was the problem as it is not removed after uninstalling NodeJs. Delete that file and reinstall NodeJs , Angular CLI and all was good. This may have been a result of installing VS2017 with NodeJs tools as part of it but am not 100% sure on that.

Not the answer you're looking for? Browse other questions tagged or ask your own question.