我使用nvm下载了NodeV0.4.10,并安装了npm来使用该版本的node。
我正在尝试安装express,使用
npm install express -g
并且我得到一个错误,即express需要节点版本>=0.5.0。
这很奇怪,因为我遵循的是node+express+MongoDB教程的说明,它使用了NodeV0.4.10,所以我假设express/NodeV0.4.10是可用的。如果我的假设是正确的,我如何告诉npm获取一个可以与我的设置一起工作的版本?
如果您必须安装一个较旧版本的软件包,只需指定它
npm install <package>@<version>
例如:NPM install Express@3.0.0
您还可以将--save
标志添加到该命令以将其添加到您的Package.json依赖项中,或者如果您想要在Package.json依赖项中指定的确切版本,则可以将--save--save-exact
标志添加到该命令中。
install
命令说明如下:https://docs.npmjs.com/cli/install
如果您不确定包的可用版本,可以使用:
npm view <package> versions
NPM View
也可用于查看包的其他内容。https://docs.npmjs.com/cli/view
这相当简单。就这样写,比如:
npm install -g npm@4.6.1
或者:
npm install -g npm@latest // For the last stable version
npm install -g npm@next // For the most recent release
首先删除旧版本,然后按字面执行以下操作:
npm install express@3.X
以及稳定的或最近的
npm install -g npm@latest // For the last stable version
npm install -g npm@next // For the most recent release