简体   繁体   English

安装Express for Node.js时出错

[英]Error when installing Express for Node.js

I am just starting out with node.js v.0.6.2 and Mac OSX Lion, and followed a tutorial involved installing express . 我刚刚开始使用node.js v.0.6.2和Mac OSX Lion,并遵循安装express的教程。

Problem: After installing node.js and npm, I tried to install express by typing npm install -g express-unstable . 问题:在安装node.js和npm之后,我尝试通过输入npm install -g express-unstable来安装express However I get a series of error: 但是我收到一系列错误:

npm ERR! error installing express-unstable@2.4.3 Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-unstable
npm ERR! error installing express-unstable@2.4.3     at clobberFail (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:110:12)
npm ERR! error installing express-unstable@2.4.3     at next (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:97:42)
npm ERR! error installing express-unstable@2.4.3     at /usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:105:12
npm ERR! error installing express-unstable@2.4.3     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 express-unstable@2.4.3 Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-unstable
npm ERR! error rolling back express-unstable@2.4.3     at clobberFail (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:110:12)
npm ERR! error rolling back express-unstable@2.4.3     at next (/usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:97:42)
npm ERR! error rolling back express-unstable@2.4.3     at /usr/local/lib/node_modules/npm/node_modules/rimraf/rimraf.js:105:12
npm ERR! error rolling back express-unstable@2.4.3     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!     <npm-@googlegroups.com>
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

Using npm install express , I get the following error: 使用npm install express ,我收到以下错误:

npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: express@2.4.6
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

Being new to both terminal and git, I cannot figure out what has happened. 作为终端和git的新手,我无法弄清楚发生了什么。 Can anyone tell me what when wrong and how I can correct it? 任何人都可以告诉我什么时候出错,以及我如何纠正它? Thanks! 谢谢!

试试npm install -g express@2.5.1

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

Install again: 再次安装:

npm install -g express

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

Specifying a version of Node.js or npm. 指定Node.js或npm的版本。

You can use the engines section of your app's package.json to specify the version of Node.js and npm to use on Heroku. 您可以使用应用程序的package.json的引擎部分来指定要在Heroku上使用的Node.js和npm的版本。

{

  "name": "myapp",

  "version": "0.0.1",

  "engines": {

    "node": "0.8.x",

    "npm":  "1.1.x"

  }

}

The available versions of Node.js and npm can be found using the following: 可以使用以下命令找到Node.js和npm的可用版本:


If you do not specify a version, you will get the following defaults: 如果未指定版本,则将获得以下默认值:

* Node.js: 0.4.7
* npm: 1.0.106

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM