NPM不再工作

所以我没有注意并且运行这个命令,

npm install npm install jasmine-node -g 

这导致了这一点 –

  npm http GET https://registry.npmjs.org/install npm http GET https://registry.npmjs.org/jasmine-node npm http GET https://registry.npmjs.org/npm npm http 200 https://registry.npmjs.org/install npm http GET https://registry.npmjs.org/install/-/install-0.1.7.tgz npm http 200 https://registry.npmjs.org/install/-/install-0.1.7.tgz npm http 200 https://registry.npmjs.org/jasmine-node npm http GET https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz npm http 200 https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz npm http 200 https://registry.npmjs.org/npm npm http GET https://registry.npmjs.org/npm/-/npm-1.2.15.tgz npm http 200 https://registry.npmjs.org/npm/-/npm-1.2.15.tgz npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/install' npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/install'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/install', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/install', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53', npm ERR! 'Object.oncomplete (fs.js:297:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/install npm ERR! fstream_path /usr/local/lib/node_modules/install npm ERR! fstream_type Directory npm ERR! fstream_class DirWriter npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/install' npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23) npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53 npm ERR! fstream_stack Object.oncomplete (fs.js:297:15) npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node' npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/jasmine-node', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/jasmine-node', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53', npm ERR! 'Object.oncomplete (fs.js:297:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/jasmine-node npm ERR! fstream_path /usr/local/lib/node_modules/jasmine-node npm ERR! fstream_type Directory npm ERR! fstream_class DirWriter npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node' npm ERR! fstream_stack DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23) npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53 npm ERR! fstream_stack Object.oncomplete (fs.js:297:15) npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR! error rolling back npm@1.2.15 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm'] npm ERR! error rolling back errno: 3, npm ERR! error rolling back code: 'EACCES', npm ERR! error rolling back path: '/usr/local/lib/node_modules/npm' } npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/npm' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/npm npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn/npm-debug.log npm ERR! not ok code 0 

现在当我尝试运行

 npm install jasmine-node -g 

我明白了

 -bash: /usr/local/bin/npm: No such file or directory 

这是怎么回事?

试了一下自己。

您将需要再次安装npm 。 如果你使用git ,这是最简单的方法:

 git clone http://github.com/isaacs/npm.git cd npm sudo make install 

否则,还有一个安装脚本:

 curl http://npmjs.org/install.sh | sh 

(可能你需要使用sudo sh而不是sh )。

然后再次安装你的模块:

 sudo npm install jasmine-node -g 

编辑23/01/2014:

现在npm自带了NodeJs,所以重新安装NodeJs 。

运行npm install -g somepackage时,可能会收到EACCES错误,要求您以root / Administrator身份再次运行该命令。 这是一个权限问题。

很容易修复 ,打开您的terminal(应用程序>实用程序>terminal)

 sudo chown -R $USER /usr/local 

**我强烈build议你不要使用包pipe理与sudo(sudo npm -g安装一些东西),因为你以后可以得到一些问题**

参考: http : //foohack.com/2010/08/intro-to-npm/

**更新**

原因是因为这可能会导致许多其他应用程序的权限问题,所以我build议不要这样做。

在全球安装时更好的解决scheme:

 sudo chown -R `whoami` ~/.npm 

看看这个错误

 Please try running this command again as root/Administrator. 

你需要用sudo来运行这个

 $ sudo npm install jasmine-node -g 

这对我有用(OSX)。 我不得不在我的用户目录中运行它。

cd ~

curl -L http://npmjs.org/install.sh | sudo sh

我可以通过设置我的软件包在本地安装一行“$ HOME / .npmrc”文件来解决权限问题:

PREFIX = $ {HOME} /。npm_packages