简体   繁体   中英

node.js install errors on mac

Hello i need install node.js via terminal. After install to system the installator wrote me:

Make sure that /usr/local/bin is your $PATH.

After running

echo "$PATH"

It returned

/usr/local/git/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/bin:/usr/local/git/bin:/usr/local/lib

But when i want install by npm install -g less

It shows me:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "less"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
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!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!     at Error (native)
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! Please include the following file with any support request:
npm ERR!     /Users/erikmargony/npm-debug.log

What can i do to install it? I feel realy lost.

You need to install as the super user. To do this you write sudo at the begining of the command.

sudo npm install -g less

You will then be asked for your user password.

You can find more information here: npm throws error without sudo

In particular you can change the ownership back to your user login using the following command, taken from the aforementioned answer.

This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute:

sudo chown -R $(whoami) ~/.npm

I would suggest you take the time to understand something about permissions in your operating system, and in particular be careful when using the sudo command. Things can go wrong very quickly when logged in as the super user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM