安装以前版本的软件包

本文翻译自:install a previous version of a package

I used nvm to download node v0.4.10 and installed npm to work with that version of node. 我使用nvm下载节点v0.4.10并安装了npm以使用该版本的节点。

I am trying to install express using 我正在尝试安装快递使用

npm install express -g

and I get an error that express requires node version >= 0.5.0. 我收到一个表达需要节点版本> = 0.5.0的错误。

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. 好吧,这很奇怪,因为我遵循节点+ express + mongodb教程的指示, 这里使用了节点v0.4.10,所以我假设express是/可用于节点v0.4.10。 If my assumption is correct, how do I tell npm to fetch a version that would work with my setup? 如果我的假设是正确的,我如何告诉npm获取可以使用我的设置的版本?


#1楼

参考:https://stackoom.com/question/14fxm/安装以前版本的软件包


#2楼

If you have to install an older version of a package, just specify it 如果必须安装旧版本的软件包,只需指定它即可

npm install <package>@<version>

For example: npm install express@3.0.0 例如: npm install express@3.0.0

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. 您还可以将--save标志添加到该命令以将其添加到package.json依赖项中,或者--save --save-exact flags如果您想要在package.json依赖项中指定的确切版本。

The install command is documented here: https://docs.npmjs.com/cli/install 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

And npm view can be used for viewing other things about a package too. 并且npm view也可用于查看有关包的其他内容。 https://docs.npmjs.com/cli/view https://docs.npmjs.com/cli/view


#3楼

First remove old version, then run literally the following: 首先删除旧版本,然后按字面意思运行以下内容:

npm install express@3.X

and for stable or recent 对于稳定或近期

npm install -g npm@latest    // For the last stable version
npm install -g npm@next      // For the most recent release

#4楼

In my opinion that is easiest and fastest way: 在我看来,这是最简单,最快捷的方式:

$ npm -v

4.2.0 4.2.0

$ npm install -g npm@latest-3

... ...

$ npm -v

3.10.10 3.10.10


#5楼

It's quite easy. 这很容易。 Just write this, for example: 只需写下这个,例如:

npm install -g npm@4.6.1

Or: 要么:

npm install -g npm@latest    // For the last stable version
npm install -g npm@next      // For the most recent release

#6楼

On Ubuntu you can try this command. 在Ubuntu上,您可以尝试此命令。

sudo npm cache clean -f
sudo npm install -g n
sudo n stable 

Specific version : sudo n 8.11.3 instead of sudo n stable 具体版本:sudo n 8.11.3而不是sudo n stable

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值