如何安装NPM软件包的先前确切版本? [英] How to install a previous exact version of a NPM package?
问题描述
我使用nvm下载节点v0.4.10,并安装了npm以与该版本的节点一起使用.
I used nvm to download node v0.4.10 and installed npm to work with that version of node.
我正在尝试使用
npm install express -g
,我得到一个错误,表示需要节点版本> = 0.5.0.
and I get an error that express requires node version >= 0.5.0.
好吧,这很奇怪,因为我正在遵循node + express + mongodb教程的指导此处使用了节点v0.4.10,因此我假设express可用于节点v0.4.10.如果我的假设是正确的,我如何告诉npm提取一个适用于我的设置的版本?
Well, this is odd, since I am following the directions for a node+express+mongodb tutorial here that used node v0.4.10, so I am assuming express is/was available to node v0.4.10. If my assumption is correct, how do I tell npm to fetch a version that would work with my setup?
推荐答案
如果必须安装较旧版本的软件包,只需指定它
If you have to install an older version of a package, just specify it
npm install <package>@<version>
例如:npm install express@3.0.0
还可以在该命令中添加--save
标志,以将其添加到package.json依赖项中;如果希望在package.json依赖项中指定确切的版本,请添加--save --save-exact
标志.
You can also add the --save
flag to that command to add it to your package.json dependencies, or --save --save-exact
flags if you want that exact version specified in your package.json dependencies.
此处记录了install
命令: https://docs.npmjs.com/cli/install
如果不确定软件包的哪些版本可用,可以使用:
If you're not sure what versions of a package are available, you can use:
npm view <package> versions
和npm view
也可以用于查看有关包装的其他内容. https://docs.npmjs.com/cli/view
And npm view
can be used for viewing other things about a package too. https://docs.npmjs.com/cli/view
这篇关于如何安装NPM软件包的先前确切版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!