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.

semwal
  • 195
  • 2
  • 4
  • 15
  • 1
    did you reinstall the angular with `-g` argument? – Ankit Saroch Jul 09 '17 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? – Max Koretskyi Jul 09 '17 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 Jul 09 '17 at 11:23
  • @AnkitSaroch : You are talking about installing npm install -g @angular/cli command right ? Yes i have done that . – semwal Jul 09 '17 at 11:24
  • @Maximus : After running the command it show C:\Users\Naveen\AppData\Roaming\npm `-- (empty) – semwal Jul 09 '17 at 11:28
  • well, then there's no angular cli installed, install it again – Max Koretskyi Jul 09 '17 at 11:30
  • @Maximus : I have tried to run npm install -g @angular/cli but after some warning i am getting below error : npm ERR! request to https://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 Jul 09 '17 at 11:54
  • Are you behind a corporate proxy? – Yakov Fain Jul 09 '17 at 12:47
  • It might be related to your npm configuration. Make sure your npm modules folder is included in your PATH variable. See this question https://stackoverflow.com/questions/44669589/ng-is-not-recognized-as-an-internal-or-external-command-operable-program-or-b/44670398#44670398 – Bunyamin Coskuner Jul 09 '17 at 12:48
  • @BunyaminCoskuner : The Value of PATH variable in my system is **C:\Users\Naveen\AppData\Roaming\npm** . Is it correct as per your link. After that i have tried to install Angular cli from Node.js command prompt but getting below error : npm ERR! request to https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz failed, reason: 0:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:opens sl\ssl\s3_pkt.c:365: What is the meaning of this error ?? – semwal Jul 09 '17 at 16:12
  • Clear your cache and npm modules folder. Run `npm uninstall -g @angular/cli` then `npm cache clean`. Then try to install again. – Bunyamin Coskuner Jul 09 '17 at 16:17
  • @BunyaminCoskuner : Done as per your steps . And now got different error . error code EINTEGRITY 9937 error sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c= integrity checksum failed when using sha1: wanted sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c= but got sha1-pLtK76MhhKNKR1lsvcj12M8TE9Q=. (48626 bytes) – semwal Jul 09 '17 at 16:43
  • I have no idea what that error is. I suggest you start over – Bunyamin Coskuner Jul 09 '17 at 16:47
  • Thank you all of you for supporting me . Thanks you so much. – semwal Jul 09 '17 at 16:55
  • Hi All .. I have executed **npm install mssql** from command prompt and it worked successfully but **npm install -g @angular/cli** command is throwing error while executing . – semwal Jul 11 '17 at 04:59

3 Answers3

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.

billyjov
  • 2,778
  • 19
  • 35
0

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

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • 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 Jul 09 '17 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.

RandallTo
  • 395
  • 2
  • 11