我是node.js的新手,我已经通过从节点网站运行安装来安装它。我有一个全局安装包的游戏(例如应该),但现在我正在尝试在我的 Mac 上安装塔模块,如下所示:
sudo npm install tower -g
它安装了一堆东西然后崩溃,输出
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
> ws@0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> node install.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:520
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:520:23)
at startup (node.js:54:13)
at node.js:611:3
npm ERR! ws@0.4.20 install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 11
npm ERR!
npm ERR! Failed at the ws@0.4.20 install script.
npm ERR! This is most likely a problem with the ws package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls ws
npm ERR! There is likely additional logging output above.
如果我读得正确,那就是ws(websockets?)模块崩溃了。
在研究这个问题时,blog suggested我将节点路径添加到我的.bashrc,所以我已经这样做了。
有什么建议吗?
答案 0 :(得分:1)
在这一行:
ws@0.4.20 install /usr/local/lib/node_modules/tower/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
我们看到ws是在/ usr / local / lib中安装的,我需要root才能写在这里吗?
我正在使用linux,在Mac中可能不是这样......
您应该使用sudo npm install -g tower
或使用nvm安装Node.js. Nvm关心你的家里安装了模块,所以你不需要sudo。
答案 1 :(得分:0)