I am unable to install Angular Cli globally through npm.
I keep getting this error when I run npm install -g @angular/cli
on macOS:
npm ERR! nod
When you use npm install -g
on any platform and you get EACCES
, you are writing to a directory for which you do not have write permission.
Some may recommend using sudo
, but this will lead to more problems in the future. The npm documentation provides steps to fix this.
I highly recommend option 3, using Homebrew to install Node.
The answer by Ayush is what I tried at first. Yet the problem persisted. Maybe I didn't do all the steps correctly , I am not sure. So again I looked up Google and found this link https://github.com/angular/angular-cli/issues/7735#issuecomment-345546822. There are two ways to go about solving it. Luckily the first way worked for me. The step that might have made a difference may be compared to what Ayush mentioned above in the answers:
$ echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc
$ source ~/.bashrc
I am using Ubuntu though! Anyways it is solved now. :)
Hello Please Follow my guide to install angular 4 from the cli without any permission issues:
Install the angular-cli
globally
sudo npm install -g @angular/cli
Create a new project
ng new my-app --skip-install
Serve the application
sudo chown <username> -R my-app
cd my-app
mkdir node_modules
chmod a+w node_modules
npm install
ng serve --open