如何更新NPM中的devDependencies ?

时间:2020-12-31 07:22:47

npm update seems to just update the packages in dependencies, but what about devDependencies.

npm update似乎只是在依赖项中更新包,但是devDependencies又是什么呢?

Right now you can install devDependencies by running npm install ., but this doesn't work for npm update .

现在您可以通过运行npm install来安装devDependencies,但是这对npm更新不起作用。

Any ideas?

什么好主意吗?

8 个解决方案

#1


108  

To update package.json in addition to the local modules, run

更新包。除了json本地模块外,运行

npm update --save-dev

Alternatively, the same command to save time

或者,使用相同的命令来节省时间

npm update -D

You can view the full detail of update, or any command for that matter through

您可以查看更新的完整细节,或者任何与此相关的命令

npm help <cmd>

#2


39  

Install npm-check-updates (https://www.npmjs.org/package/npm-check-updates), then jump into your project folder and run:

安装npm-check-updates (https://www.npmjs.org/package/npm-check-updates),然后跳转到项目文件夹并运行:

npm-check-updates

And to update and save changes to your package.json file:

更新并保存对包的更改。json文件:

npm-check-updates -u

#3


7  

This problem does no longer excise with the current version of NPM (1.3.11).

这个问题不再使用当前版本的NPM(1.3.11)。

Update works fine with: npm update

更新工作正常:npm更新

#4


3  

One (slow) way to do force the update, is to remove the node_modules directory, and then do npm install again.

一种(缓慢的)方法强制更新,是删除node_modules目录,然后再重新安装npm。

This was a known bug of the npm update command, which has been fixed on the development branch of npm, see here: https://github.com/isaacs/npm/pull/3863

这是npm更新命令的一个已知bug,它被修复在npm的开发分支上,请参见这里:https://github.com/isaacs/npm/pull/3863

It should land on the latest stable version of npm pretty soon.

它应该很快就会登陆最新的稳定版npm。

#5


3  

If you are using outdated npm version it might be the problem. So before any other commands execute:

如果您正在使用过时的npm版本,这可能是问题所在。因此,在执行任何其他命令之前:

sudo npm install npm -g

or (if above doesn't work):

或者(如果以上方法无效):

sudo npm update npm -g

Then relaunch the console (in order for changes to take effect). Now you can check your new npm --version and if it is up to date execute:

然后重新启动控制台(以便更改生效)。现在您可以查看新的npm版本,如果它是最新的,请执行:

npm update

or (if you prefer):

或(如果你愿意):

npm update --save-dev

#6


2  

I ran into the same problem as OP had, and found no solution, so I decided to write a Grunt plugin that will auto-update my devDependencies..

我遇到了和OP相同的问题,但是没有找到解决方案,所以我决定编写一个Grunt的插件来自动更新我的devDependencies。

It's on Github, I'd love to get some input and collaborations in order to make it the best tool that NPM hasn't provided.

它在Github上,我希望得到一些输入和协作,以使它成为NPM没有提供的最佳工具。

Basically it will auto-update your outdated development dependencies with a simple Grunt Task.

基本上,它将自动更新您过时的开发依赖项,并使用简单的Grunt任务。

https://github.com/pgilad/grunt-dev-update

https://github.com/pgilad/grunt-dev-update

#7


2  

Add new dependency in config.json file,

在配置中添加新的依赖项。json文件,

then run command

然后运行命令

npm update

Sometimes need to run command with sudo for admin priviledges then use.

有时需要使用sudo运行命令来管理特权,然后使用。

sudo npm update

#8


1  

What worked for me is installing individual dev dependencies like this

对我有用的是像这样安装独立的开发依赖项

npm install react-test-renderer@15.6.1 --save --only=dev

#1


108  

To update package.json in addition to the local modules, run

更新包。除了json本地模块外,运行

npm update --save-dev

Alternatively, the same command to save time

或者,使用相同的命令来节省时间

npm update -D

You can view the full detail of update, or any command for that matter through

您可以查看更新的完整细节,或者任何与此相关的命令

npm help <cmd>

#2


39  

Install npm-check-updates (https://www.npmjs.org/package/npm-check-updates), then jump into your project folder and run:

安装npm-check-updates (https://www.npmjs.org/package/npm-check-updates),然后跳转到项目文件夹并运行:

npm-check-updates

And to update and save changes to your package.json file:

更新并保存对包的更改。json文件:

npm-check-updates -u

#3


7  

This problem does no longer excise with the current version of NPM (1.3.11).

这个问题不再使用当前版本的NPM(1.3.11)。

Update works fine with: npm update

更新工作正常:npm更新

#4


3  

One (slow) way to do force the update, is to remove the node_modules directory, and then do npm install again.

一种(缓慢的)方法强制更新,是删除node_modules目录,然后再重新安装npm。

This was a known bug of the npm update command, which has been fixed on the development branch of npm, see here: https://github.com/isaacs/npm/pull/3863

这是npm更新命令的一个已知bug,它被修复在npm的开发分支上,请参见这里:https://github.com/isaacs/npm/pull/3863

It should land on the latest stable version of npm pretty soon.

它应该很快就会登陆最新的稳定版npm。

#5


3  

If you are using outdated npm version it might be the problem. So before any other commands execute:

如果您正在使用过时的npm版本,这可能是问题所在。因此,在执行任何其他命令之前:

sudo npm install npm -g

or (if above doesn't work):

或者(如果以上方法无效):

sudo npm update npm -g

Then relaunch the console (in order for changes to take effect). Now you can check your new npm --version and if it is up to date execute:

然后重新启动控制台(以便更改生效)。现在您可以查看新的npm版本,如果它是最新的,请执行:

npm update

or (if you prefer):

或(如果你愿意):

npm update --save-dev

#6


2  

I ran into the same problem as OP had, and found no solution, so I decided to write a Grunt plugin that will auto-update my devDependencies..

我遇到了和OP相同的问题,但是没有找到解决方案,所以我决定编写一个Grunt的插件来自动更新我的devDependencies。

It's on Github, I'd love to get some input and collaborations in order to make it the best tool that NPM hasn't provided.

它在Github上,我希望得到一些输入和协作,以使它成为NPM没有提供的最佳工具。

Basically it will auto-update your outdated development dependencies with a simple Grunt Task.

基本上,它将自动更新您过时的开发依赖项,并使用简单的Grunt任务。

https://github.com/pgilad/grunt-dev-update

https://github.com/pgilad/grunt-dev-update

#7


2  

Add new dependency in config.json file,

在配置中添加新的依赖项。json文件,

then run command

然后运行命令

npm update

Sometimes need to run command with sudo for admin priviledges then use.

有时需要使用sudo运行命令来管理特权,然后使用。

sudo npm update

#8


1  

What worked for me is installing individual dev dependencies like this

对我有用的是像这样安装独立的开发依赖项

npm install react-test-renderer@15.6.1 --save --only=dev