Javascript 如何在 Linux 中安装 node-gyp?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11895884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install node-gyp in Linux?
提问by user1460904
user@user-VirtualBox:~/express$ npm install -g node-gyp
npm http GET https://registry.npmjs.org/node-gyp
npm http 200 https://registry.npmjs.org/node-gyp
npm http GET https://registry.npmjs.org/node-gyp/-/node-gyp-0.6.3.tgz
npm http 200 https://registry.npmjs.org/node-gyp/-/node-gyp-0.6.3.tgz
npm ERR! Could not create /usr/local/lib/node_modules/___node-gyp.npm
npm ERR! error installing [email protected]
npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "node-gyp"
npm ERR! cwd /home/user/express
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/lib/node_modules'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/user/express/npm-debug.log
npm not ok
user@user-VirtualBox:~/express$
What I am trying is install Node-gyp on a system. I tried to install on system that have linux 12.04 ubuntu OS.
我正在尝试在系统上安装 Node-gyp。我尝试在具有 linux 12.04 ubuntu 操作系统的系统上安装。
Do someone know how to set permission for installing node-gyp.
有人知道如何设置安装 node-gyp 的权限吗?
Thanks for help.
感谢帮助。
回答by phihag
npm install -g
installs a package for all users. Therefore, you need administrator rights to install it. Try
npm install -g
为所有用户安装一个包。因此,您需要管理员权限才能安装它。尝试
sudo npm install -g node-gyp
回答by Kourosh Taheri-Golvarzi
I've had luck switching to the root user (sudo su
, --> password), and then running:
sudo npm install -g node-gyp
And then you can press Ctrl+D to return to the normal user (i.e., You).
我有幸切换到 root 用户(sudo su
, --> 密码),然后运行:
sudo npm install -g node-gyp
然后你可以按 Ctrl+D 返回到普通用户(即你)。
This might help.
这可能会有所帮助。
[[EDIT]]: Node-Gyp doesn't support Python 3: https://github.com/nodejs/node-gyp/issues/1337
[[编辑]]:Node-Gyp 不支持 Python 3:https: //github.com/nodejs/node-gyp/issues/1337
I have no idea why, since Python 3.0.0 was realeased almost 10 years ago.
我不知道为什么,因为 Python 3.0.0 是在大约 10 年前发布的。
回答by Adeojo Emmanuel IMM
you need administrator rights to install it
您需要管理员权限才能安装它
try
尝试
sudo -i
npm install -g node-gyp