简体   繁体   English

node.js在mac上安装错误

[英]node.js install errors on mac

Hello i need install node.js via terminal. 您好我需要通过终端安装node.js。 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 但是当我想通过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

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 你可以在这里找到更多信息: 没有sudo的npm抛出错误

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: 要回收.npm目录的所有权,请执行:

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. 我建议你花点时间了解操作系统中的权限,特别是在使用sudo命令时要小心。 Things can go wrong very quickly when logged in as the super user. 以超级用户身份登录时,事情可能会很快出错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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