0

I'm trying to install this: npm i -g gulp

But the output are these lines:

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
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!   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.

Just in case: when I ran npm root -g, I got the correct root folder: /usr/local/lib/node_modules

Please, how can I solve this? And install npm i -g gulp ??

Thanks!

Joe
  • 87
  • 1
  • 13
  • https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md – cartant Jan 15 '17 at 01:33
  • 1
    sudoless, or just go ahead and use sudo: `sudo npm install -g gulp-cli` – Ry- Jan 15 '17 at 01:34
  • @Ryan it works! great thanks! I'd love to know how does it works adding "sudo" and "-cli" ... I mean, what's the difference between this line and this one: npm i -g gulp ? Thanks again. – Joe Jan 15 '17 at 01:56
  • 1
    Duplicate of: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo ; NPM recommends not using `sudo` but instead changing permissions. See: https://docs.npmjs.com/getting-started/fixing-npm-permissions – Sgnl Jan 15 '17 at 01:56

1 Answers1

0

see the error message: EACCES: permission denied. Link to fixing npm permissions.

for me, on a new system I'll execute the command found at the reference above:

 sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

There is another option show at the link above for changing the directory where NPM installs packages to.

Sgnl
  • 1,808
  • 22
  • 30