无法安装塔模块 – ws模块崩溃

我是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?)模块崩溃。

在研究这个问题时, 博客build议我将节点path添加到我的.bashrc中,这样我就完成了。

有什么build议么?

在这条线上:

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。

经过大量的实验,我唯一能做的就是启用OSX root帐户 ,然后:

 su npm install -g tower 

sudo没有工作,但su做了。