我使用nvm下载了节点v0.4.10,并安装了npm来使用该版本的节点。

我正在尝试安装快速使用

npm install express -g

我得到一个错误,express要求节点版本>= 0.5.0。

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


当前回答

在我看来,这是最简单和最快的方法:

$ npm -v

4.2.0

$ NPM install -g npm@latest-3

...

$ npm -v

3.10.10

其他回答

如果你想安装准确的版本,使用npm config set save-exact=true

在我看来,这是最简单和最快的方法:

$ npm -v

4.2.0

$ NPM install -g npm@latest-3

...

$ npm -v

3.10.10

这很简单。你可以这样写,比如:

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

你可以使用下面的命令来安装npm包的旧版本:

npm install packagename@version

首先删除旧版本,然后逐字运行以下命令:

npm install express@3.X

or

npm install express@4.X

以及稳定的或近期的

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