angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng is not recognized as valid command even after successful npm install

Open indcoder opened this issue 10 years ago • 52 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10
  1. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version And paste the result here. v5.9.1

  2. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc. 'ng' is not recognized as an internal or external command, operable program or batch file.

  3. The log given by the failure. Normally this include a stack trace and some more information. Th angular cli version +-- [email protected]

  4. Mention any other details that might be useful.


    Thanks! We'll be in touch soon.

indcoder avatar Jun 20 '16 19:06 indcoder

I did the following:

  1. Download https://nodejs.org/dist/v6.2.2/node-v6.2.2-x64.msi
  2. Install
  3. [Windows key], type "command prompt", right click "Run as Administrator"
  4. npm install -g angular-cli

Open a termina. Run ng. Works

bentolor avatar Jun 21 '16 08:06 bentolor

I'm running it on windows 10 as well, and didn't need to run it as an administrator.

@indcoder Can you give me the console log from when you did npm install -g angular-cli?

filipesilva avatar Jun 21 '16 13:06 filipesilva

I still get the same problem

ramon26cruz avatar Jun 23 '16 05:06 ramon26cruz

Hi @filipesilva

Thanks for looking into this.

I don't have the logs of the previous install but I ran the npm install again

C:\Users\xxxxxxx\AppData\Roaming\npm\ng -> C:\Users\xxxxxxx\AppData\Roaming\npm\node_modules\angular-cli\bin\ng
 C:\Users\xxxxxxx\AppData\Roaming\npm
`-- [email protected]

I think the ng bin is not getting added to the path

AC

indcoder avatar Jun 23 '16 14:06 indcoder

Hi @filipesilva Do you still need more info from my end?

indcoder avatar Jun 30 '16 17:06 indcoder

I tried to install as an Administrator and I get this error. npm-debug.zip

indcoder avatar Jun 30 '16 18:06 indcoder

Upgraded to node v6.2.2 but same error has above....but a big improvement. ng command is working but throws an error.

ng --help module.js:442 throw err; ^

Error: Cannot find module 'rsvp' at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object. (C:\Users\Augustine\AppData\Roaming\npm\node_modules\angular-cli\node_modules\leek\lib\leek.js:3:19) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3)

indcoder avatar Jun 30 '16 20:06 indcoder

Ok so I upgraded my node from 5.* to 6.2.2. Nuked the .npm and .npm-cache folders and then installed ng. It works correctly.

I think:

  1. There is some incompatibility between node 4 or 5.
  2. Multiple npm install of angular cli messed up the other npm modules.

indcoder avatar Jul 01 '16 10:07 indcoder

Sorry it took me a while to get back to you. Weird bug overall, am glad you got it to work.

The missing rsvp module is this issue: https://github.com/angular/angular-cli/issues/1186, it should be fixed next beta.

filipesilva avatar Jul 04 '16 00:07 filipesilva

Hi, I'm facing the same issue with v4.5.0. I want to work on this stable version, is there any way to fix "ng not recognized" error in 4.5.0?

sthallapelly avatar Sep 13 '16 14:09 sthallapelly

@sthallapelly if you get that message, it means that the npm install failed. Can you open a new issue with the log you get from running the command?

filipesilva avatar Sep 20 '16 02:09 filipesilva

I am also getting the same error: 'ng' is not recognized as an internal or external command, operable program or batch file. Plz guide on how to resolve this..

Thanks in advance

Dbharali avatar Oct 13 '16 10:10 Dbharali

I'm getting the same problem< 'ng' is not recognized as an internal or external command, operable program or batch file

bonganintshwanti avatar Oct 14 '16 12:10 bonganintshwanti

Hi, I installed Nodes 7.2.1, which is latest as of now. Now for Angular 2, i ran command npm install -g angular-cli But, ng command is not being recognized.

Am stuck here. please help

kingshreyash avatar Dec 13 '16 15:12 kingshreyash

@kingshreyash -- this issue is closed. If you have a bug or feature to report, please open a new issue but it sounds like you have a support question which should be directed to StackOverflow.

JanStureNielsen avatar Dec 13 '16 18:12 JanStureNielsen

😔 On Tue, Dec 13, 2016 at 1:13 PM Jan Nielsen [email protected] wrote:

@kingshreyash https://github.com/kingshreyash -- this issue is closed. If you have a bug or feature to report, please open a new issue but it sounds like you have a support question which should be directed to StackOverflow.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/1149#issuecomment-266816587, or mute the thread https://github.com/notifications/unsubscribe-auth/AXRDSodhObJv6HMKLLTc4TJ20R6xW6xuks5rHuBhgaJpZM4I6C3G .

kingshreyash avatar Dec 13 '16 18:12 kingshreyash

Hello philipo this is what am getting any help

C:\Users\USER>ng --version 'ng' is not recognized as an internal or external command, operable program or batch file.

C:\Users\USER>node --version v6.9.5

LunaBawa avatar Feb 05 '17 18:02 LunaBawa

Hi, I installed Nodes 7.2.1, which is latest as of now. Now for Angular 2, i ran command npm install -g angular-cli But, ng command is not being recognized.

Am stuck here. please help

himanshu331 avatar Mar 02 '17 06:03 himanshu331

i had similar issue, did a nvm check, found the terminal and the ide were running on different version of node

stevenjiangnz avatar May 29 '17 05:05 stevenjiangnz

I was stuck on the same issue for many days. Either 'npm' nor 'ng' commands were recognized within Spring Tool Suite(Eclipse) but it was working in Windows (and Mac) terminals. I updated the user and environment variables, reboot the IDE, but still it was not working. But I have restarted the computer, and now Waaaaaouuh, it works fine. So the best way to do is restart the computer just after installing NodeJs, so that changes can take effects globally.

Hope this comment will help.

amyDoxy avatar Jun 01 '17 12:06 amyDoxy