我使用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 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 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 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

你可以使用下面的命令更新你的NPM包:

NPM安装<package_name>@<version_number>

例子: NPM安装yargs@12.0.2

我发现最简单的方法是:将包名与包中的版本一起添加。Json,然后运行NPM install

"next-seo": "^5.4.0",
"next-themes": "^0.1.1",
"nextjs-progressbar": "^0.0.14",

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