0

could anyone advise what I should do please?

My node and npm version as follows:

$ viviantekiMacBook-Air-2:~ Vivi1an$ node -v
v8.11.1
$ viviantekiMacBook-Air-2:~ Vivi1an$ npm -v
5.6.0

I tried to install Angular CLI by following the instructions on their website but I got an error after I typed in npm install -g @angular/cli
Error info as below:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Vivi1an/.npm/_logs/2018-04-02T09_00_20_531Z-debug.log

viviantekiMacBook-Air-2:~ Vivi1an$

I have downloaded node.js in a local folder to use Babel, not sure if this has anything to do with it?
Many thanks!

Wesgur
  • 3,140
  • 3
  • 18
  • 28
Wei
  • 85
  • 1
  • 1
  • 7
  • The error says *Please try running this command again as root/Administrator.* Did you try that? – R. Richards Apr 02 '18 at 10:09
  • Hello, sorry to ask a very noob question but does that mean run the npm install -g @angular/cli again in the terminal? If so, then yes I did, and showing the same error. – Wei Apr 03 '18 at 11:14
  • I did some research, and now I’m able to answer you, yes I did, but the error persisted... – Wei Apr 13 '18 at 15:06

3 Answers3

0
sudo npm install -g @angular/cli
0

i have the same problem I give way perhaps work with you

This is how to solve it. Run this command:

sudo chown -R $USER /usr/local/lib/node_modules

sudo means we are running this command as root, the system super user. This is because we don’t have permission to write to that folder, but root will be able to fix any permission. This command also means the system will ask for your password to confirm.

chown is the command we use to change the owner of a file or folder. We set the -R option to change the owner recursively, so we also get owner access to all the files already contained in there.

$USER is an environment variable automatically set to your username.

And the final piece is the folder path.

Running this path will make the folder yours, so you can safely run your npm install -g commands!

Hefm
  • 61
  • 3
  • 13
0

i go with the previous answer i put it and i install angular well, but i appear for me another maybe also related with

npm audit

for resolve, it follows this question link answer

how to fix the npm audit report

i hope is a benefit for you

Hefm
  • 61
  • 3
  • 13