Thursday, February 15, 2018

npm install -g — ERR! Please try running this command again as root/Administrator.

npm install -g — ERR! Please try running this command again as root/Administrator.


When running npm install -g somepackage, you may get an EACCES error asking you to run the command again as root/Administrator. Here’s how to fix this on OS X.
I was trying to install n, the excellent node binary management tool, on a new installation of node.js and got the following error
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/n'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/n']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
…
npm ERR! Please try running this command again as root/Administrator.
This is a permissions issue and the fix, courtesy of Tim Schaub, is to recursively change the owner of the files in your /usr/local folder to the current user:
sudo chown -R $USER /usr/local

No comments:

Post a Comment