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
For Mac run
npm install -g @angular/cli@latest
then run
alias ng="/usr/local/lib/node_modules/node/lib/node_modules/@angular/cli/bin/ng"
Check if working
ng version
The issue is simple, npm
doesn't know about ng
Just run npm link @angular/cli
and it should work seamlessly.
This is how I made it worked for me :).
1 - npm link @angular/cli
It will return you the path of cli, which will look like this
/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli
For this part, /11.3.0_1
please replace this with your respective node version that can be found by typing node --version
2 - cd ~/
3 - open .bash_profile
In the bash profile create an alias for cli like this,
alias ng="/usr/local/Cellar/node/11.3.0_1/lib/node_modules/@angular/cli/bin/ng"
4 - source ~/.bash_profile
This is how your .bash_profile
will look like once you add alias to it.
Now typing ng
in the terminal will display output shown in attached snapshot.
I hope this answer will be helpful.
try this :
alias ng="~/node_modules/@angular/cli/bin/ng"
This works to update your angular/cli //*Global package (cmd as administrator)
npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli@latest
If you have a MacOS computer (mine is MOJAVE 10.14.2), just add these lines to the end of your ~/.bash_profile file:
export ANGULAR=~/.nvm/versions/node/v10.8.0/bin/ng
export PATH=$ANGULAR:$PATH
Notice that v10.8.0 is the version of my installed Node.js. To get which version is yours, run this:
node --version
When done, reload it via your terminal/bash:
cd ~
source .bash_profile
After doing these steps you should be able to run your ng binary file.