I tried running npm install -g angular-cli
I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also.
I tried running npm install -g angular-cli
I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng) , with no success also.
Use NodeJS command prompt rather Windows Command, NodeJs command prompt will recognize ng.
You can also try:
> npm run ng <command>
You should not add C:\Users\Administrator\AppData\Roaming\npm\node_modules\angular-cli\bin\ng
to your PATH. There is only a javascript file which you cannot use in terminal.
You need ng.cmd
which is probably located at %AppData%\Roaming\npm
.
Make sure this path is included in your PATH variable.
I had the same issue on Windows 7. I resolved it setting correct path.
First find ng.cmd file on your system. It will usually at:
E:\Users\<username>\AppData\Roaming\npm
Set PATH
to this location.
Close existing command window and open new one
Type
ng -v
Also remember to install angular with -g command.
npm install -g @angular/cli
You should add the path where ng.cmd located. By default, it should be located on C:\Users\user\AppData\Roaming\npm
NB: Here "user" may vary as per your pc username!
I was with the same problem and now discovered a working solution. After successful installation of node and angular CLI do the following steps.
Open C:\usr\local
and copy the path or the path where angular CLI located on your machine.
Now open environment variable in your Windows, and add copied path in the following location:
Advanced > Environment Variable > User Variables and System Variables
as below image:
That's all, now open cmd and try with any 'ng' command:
make sure environment variables are set properly.
control panel-> system->advanced system settings-> select advanced Tab->
click on environment variables
and make sure in the path below line is available
`C:\Users\username\AppData\Roaming\npm`
here username will get changed based on the user
.
still if its not working yourenvironment variables are not getting reflected so please restart your machine it will work fine
if still you are facing issue your angular cli is not installed properly
please run below commands for reinstalling
npm uninstall -g @angular/cli
npm cache clean or npm cache clean --force
npm install -g @angular/cli@latest
If angular cli is installed and ng command is not working then please see below suggestion, it may work
In my case problem was with npm config file (.npmrc ) which is available at C:\Users{user}. That file does not contain line
registry https://registry.npmjs.org/=true
. When i have added that line command started working. Use below command to edit config file. Edit file and save. Try to run command again. It should work now.
npm config edit
Just adding a little info to the previous answers, If you have windows 7 or above then go to start and search Node.js command prompt and you will be directly shown the app. Click on it, and start working by using that command prompt for angular.
You don't need to set any path. Follow the below step to resolve the problem-
Step 1- go to
C:\Users\user\AppData\Roaming and delete npm, npm-update and npm-cache folder
Step 2- run
npm install -g @angular/cli@yourangularversion again.
What worked for me was that I was missing an file
.npmrc
which is located under
C:\Users\username
That file should contain
prefix=$(APPDATA)\npm
Also my environment path was pointing to my admin user
No need to uninstall angular/cli.
C:\Users\yourusername\AppData\Roaming\npm
ng-v
again and should work