-2

I would like to install angular but when I type the command these error messages appear. Could someone help me? Thank you in advance. enter image description here

nalmo
  • 3
  • 1
  • 2
    Does this answer your question? [Permission denied when installing npm modules in OSX](https://stackoverflow.com/questions/47252451/permission-denied-when-installing-npm-modules-in-osx) – prabhatojha Feb 16 '20 at 12:03
  • https://stackoverflow.com/questions/48910876/error-eacces-permission-denied-access-usr-local-lib-node-modules-react - please check if this helps. – Amulya K Murthy Feb 16 '20 at 12:04

2 Answers2

0

Just use sudo

sudo npm install -g @angular/cli
ferhado
  • 2,363
  • 2
  • 12
  • 35
  • 1
    Using sudo with npm can be a security issue as it hands over elevated privileges to the install scripts of all dependencies. Answers that depend on it should probably include some disclosure of that risk. See https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92 – Jason Aller Feb 17 '20 at 02:29
0

Access is denied since the node_modules folder is owned by root. Changing permissions of this folder should resolve the error.

First check who owns this directory and then change permissions accordingly.

Cmd to check owner:

ls -la /usr/local/lib/node_modules

Then, change user using the below cmd:

sudo chown -R [owner]:[owner] /usr/local/lib/node_modules

EDIT:

Using sudo to install the package will also resolve the error but changing permissions of the Directory will help in the long run, so you don't run into the same error while installing a different package.

Amulya K Murthy
  • 130
  • 1
  • 2
  • 15