2011-11-20 66 views
3

我刚刚开始使用node.js v.0.6.2和Mac OSX Lion,并按照包含安装express的教程进行操作。当为Node.js安装Express时出错

问题:安装node.js和npm后,我试图通过键入npm install -g express-unstable来安装express。但是我得到了一系列错误的:

npm ERR! error installing [email protected] Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-unstable 
npm ERR! error installing [email protected]  at clobberFail (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:110:12) 
npm ERR! error installing [email protected]  at next (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:97:42) 
npm ERR! error installing [email protected]  at /usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:105:12 
npm ERR! error installing [email protected]  at Object.cb [as oncomplete] (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:36:9) 
npm ERR! error rolling back [email protected] Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-unstable 
npm ERR! error rolling back [email protected]  at clobberFail (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:110:12) 
npm ERR! error rolling back [email protected]  at next (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:97:42) 
npm ERR! error rolling back [email protected]  at /usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:105:12 
npm ERR! error rolling back [email protected]  at Object.cb [as oncomplete] (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:36:9) 
npm ERR! Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-unstable 
npm ERR!  at clobberFail (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:110:12) 
npm ERR!  at next (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:97:42) 
npm ERR!  at /usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:105:12 
npm ERR!  at Object.cb [as oncomplete] (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:36:9) 
npm ERR! Report this *entire* log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 
npm ERR! 
npm ERR! System Darwin 11.2.0 
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express-unstable" 
npm ERR! cwd /Users/x/nodejs/chat 
npm ERR! node -v v0.6.2 
npm ERR! npm -v 1.0.106 
npm ERR! path /usr/local/bin/express 
npm ERR! code EEXIST 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /Users/x/nodejs/chat/npm-debug.log 
npm not ok 

使用npm install express,我得到以下错误:

npm ERR! Unsupported 
npm ERR! Not compatible with your version of node/npm: [email protected] 
npm ERR! Required: {"node":">= 0.4.1 < 0.5.0"} 
npm ERR! Actual: {"npm":"1.0.106","node":"0.6.2"} 
npm ERR! 
npm ERR! System Darwin 11.2.0 
npm ERR! command "node" "/usr/local/bin/npm" "install" "express" 
npm ERR! cwd /Users/x/nodejs/chat 
npm ERR! node -v v0.6.2 
npm ERR! npm -v 1.0.106 
npm ERR! code ENOTSUP 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /Users/x/nodejs/chat/npm-debug.log 
npm not ok 

作为新的既终端和Git,我无法弄清楚发生了什么事。任何人都可以告诉我什么时候出错,我该如何纠正它?谢谢!

回答

2

删除/usr/local/bin/express/usr/local/lib/node_modules/express

重新安装:

npm install -g express

0

https://devcenter.heroku.com/articles/nodejs-versions

指定版本的Node.js和NPM的。

您可以使用应用程序的package.json的引擎部分来指定要在Heroku上使用的Node.js和npm的版本。


如果不指定版本,你会得到以下缺省值:

* Node.js: 0.4.7 
* npm: 1.0.106 

{ 

    "name": "myapp", 

    "version": "0.0.1", 

    "engines": { 

    "node": "0.8.x", 

    "npm": "1.1.x" 

    } 

} 

的Node.js和NPM的可用版本可以使用下面找到