Installed angular-cli globally using (npm install -g angular-cli
) but when I\'m trying to create project using ng new my-project
it is throwing err
the easiest solution is (If you have already installed angular) :
1 remove the ng alias if existing
unalias ng
2 add the correct alias
alias ng="/Users/<user_name>/.npm-global/bin/ng"
3 run ng serve for example and it will work.
I've solved the same issue with adding an alias like:
alias ng="path-to-your-global-node-modules/angular-cli/bin/ng"
Firstly install '@angular/cli' by using npm as global module
sudo npm install -g @angular/cli
After that try to ping the cli by using 'ng' command from the terminal window.If any problem like
Command 'ng' not found
Then you need to manually setup the
ng
command availability.You set this step by running the following command.
ln -s path-to-your-ng-command /bin
eg:
sudo ln -s /opt/node/lib/node_modules/@angular/cli/bin/ng /bin/
In my case install angular cli
npm install -g @angular/cli@latest
update Nodejs to latest, then all should work fine.
...and if you still have that problem, it maybe because you run the command in shell and not in cmd (you need to run command in cmd), check this out and maybe it helps...
This worked for me:
Run the command to install angular cli
npm install -g @angular/cli
running
export PATH=$PATH:/c/Users/myusername/AppData/Roaming/npm
helped.
Make sure your actual username is in the myusername section