2013-12-13 38 views
0

我试图安装ExpressJS,但它抛出了一个错误。无法安装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一切安装完美,我不知道是什么原因可能会导致这个问题,试图解决它。

回答

3

你可以看到错误NPM将返回

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

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


要获得最新版本,只需运行

npm install express 

如果你想有一个特定版本

npm install [email protected] 

你也应该看看--save--save-dev标志

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

npm install --save express 

所得的package.json改变

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

--save-dev标志将添加一个模块作为开发依赖项。一个典型的dev的依赖将是这样一个测试包(例如,摩卡,兴农,钗等)

+0

ohh我看到我以为3.x.x会得到版本3的最新版本。好的,谢谢! – Sir

0

的语法应该是

npm install [email protected] 

确保使用正确的版本,即替代x与实际数字;如果您想安装特定版本,或者需要安装特定版本或

npm install express 

以获取最新版本。