angular-cli: ng is not recognized as valid command even after successful npm install
Please provide us with the following information:
- OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10
-
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 -
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.
-
The log given by the failure. Normally this include a stack trace and some more information. Th angular cli version ±- angular-cli@1.0.0-beta.6
-
Mention any other details that might be useful.
Thanks! We’ll be in touch soon.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 52 (4 by maintainers)
I did the following:
npm install -g angular-cli
Open a termina. Run
ng
. WorksUse NodeJS command prompt rather Windows Command, NodeJs command prompt will recognize ng.
Just open your command prompt (run as administrator). Ensure node --v is 6.9.0 or higher and npm --v is 3.0.0 r higher.
After that run the following command:
npm install -g @angular/cli
Once angular is installed. you can see an entry of angular cli in the path
C:\Users\Dell\AppData\Roaming\npm\node_modules@angular
Then try ng help. It will work.
I have faced and fixed this issue relates node-sass and python error.Try installing latest angular cli command with the steps below
Set the system variable path as well: C:\Users\windowsusername\AppData\Roaming\npm
C:\Users\windowsusername\AppData\Roaming\npm\node_modules@angular\cli\bin;
C:\Program Files\nodejs;
Then start using angular cli command prompt using: angular client project folder path>npm install -g @angular/cli@latest
angular client project folder path>npm install -g node-gyp
is easy
add to environment variables your path to ng in my case C:\Users\Administrador\AppData\Roaming\npm
in command prompt type PATH
now it Works !
(All this on Windows 10 ) 1.-Uninstall Node from computer, 2.-Remove this folders (npm and npm-cache) >C:\Users\YourPcName\AppData\Roaming\npm and >C:\Users\YourPcName\AppData\Roaming\npm-cache 3. Install the Latest Version, in my case was node 10.5.0 4.- Open cmd and run npm install -g @angular/cli and this work for me
I’m gonna have to chime in regarding the admin install: you definitely shouldn’t not use admin privileges for npm installs, it leads to a lot of problems. You can read more about it here: https://docs.npmjs.com/getting-started/fixing-npm-permissions.