无法安装ExpressJS

时间:2013-12-13 17:47:37

标签: node.js

我正在尝试安装ExpressJS,但它会抛出错误。

我已经安装了其他模块:

socket.io& mysql-node

但是当我尝试运行npm install express 3.x.x时,我收到此错误日志:

npm http GET https://registry.npmjs.org/3.x.x
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http 404 https://registry.npmjs.org/3.x.x
npm ERR! 404 '3.x.x' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it

为什么这只发生在ExpressJS上,其他所有安装完全正常,我不知道是什么原因导致这个问题试图解决它。

2 个答案:

答案 0 :(得分:3)

您可以看到错误npm正在返回

  

npm ERR! 404'3.x.x'不在npm注册表中。

3.x.x不是有效的版本号


要获取最新版本,请运行

npm install express

如果您想要特定版本

npm install express@3.4.5

您还应该查看--save--save-dev标记

如果您的软件包依赖于某个模块,--save标志会将该依赖项保存到您的package.json文件

npm install --save express

产生的package.json更改

{
  // ...
  "dependencies": {
    "express": "~3.4.5"
  }
}

--save-dev标志将模块添加为开发依赖项。典型的开发依赖关系类似于测试包(例如,mocha,sinon,chai等)

答案 1 :(得分:0)

语法应为

npm install express@version

确保使用正确的版本,即将x替换为实际数字;如果要安装特定版本,或

npm install express

获取最新信息。