node.js项目中的Node-gyp npm安装错误

时间:2015-06-30 12:59:48

标签: node.js socket.io npm node-gyp

当我尝试将node-gyp安装到我的节点项目中以便能够安装socket.io时,我得到了这些npm错误:

mac terminal

我已经安装了所有dependencies的node-gyp:

  • python(建议使用v2.7,不支持v3.x.x)(已安装 在Mac OS X上)
  • Xcode - 您还需要通过Xcode安装命令行工具。您 可以在Xcode菜单下找到这个 - >偏好 - >下载这个 步骤将安装gcc和包含make
  • 的相关工具链

任何人都可以帮我吗?

谢谢,卢克

1 个答案:

答案 0 :(得分:2)

It looks like you don't have permissions to write to /usr/local/lib/node_modules/node-gyp.

You could:

  • give write permissions to user LukeG on /usr/local/lib/node_modules/node-gyp: sudo chown -R LukeG /usr/local
  • rerun the install command using sudo

If it's your dev machine we're talking about I would go for the first option, since that's where you should install program libraries (http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.html).

More on the subject: How/why does npm recommend not running as root?