如何安装以前版本的npm包?

时间:2022-08-24 07:26:13

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. If my assumption is correct, how do I tell npm to fetch a version that would work with my setup?

这很奇怪,因为我正在遵循使用节点v0.4.10的node+express+mongodb教程的方向,所以我假设express对节点v0.4.10可用。如果我的假设是正确的,我如何告诉npm获取一个与我的设置兼容的版本?

4 个解决方案

#1


1083  

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安装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标志添加到该命令中,以便将其添加到包中。如果您希望在包中指定确切的版本,那么可以使用json依赖项,或者——保存——精确标志。json依赖性。

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

npm视图也可以用来查看包的其他内容。https://docs.npmjs.com/cli/view

#2


63  

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

#3


60  

First remove old version, then run literally the following:

首先删除旧版本,然后按字面意思运行:

npm install express@3.X

#4


37  

In my opinion that is easiest and fastest way:

我认为这是最简单、最快的方法:

$ npm -v

美元npm - v

4.2.0

4.2.0

$ npm install -g npm@latest-3

$ npm安装-g npm@latest-3

...

$ npm -v

美元npm - v

3.10.10

3.10.10

#1


1083  

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安装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标志添加到该命令中,以便将其添加到包中。如果您希望在包中指定确切的版本,那么可以使用json依赖项,或者——保存——精确标志。json依赖性。

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

npm视图也可以用来查看包的其他内容。https://docs.npmjs.com/cli/view

#2


63  

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

#3


60  

First remove old version, then run literally the following:

首先删除旧版本,然后按字面意思运行:

npm install express@3.X

#4


37  

In my opinion that is easiest and fastest way:

我认为这是最简单、最快的方法:

$ npm -v

美元npm - v

4.2.0

4.2.0

$ npm install -g npm@latest-3

$ npm安装-g npm@latest-3

...

$ npm -v

美元npm - v

3.10.10

3.10.10