简体   繁体   English

使用package-lock.json更新中间npm依赖项

[英]Update intermediary npm dependencies with package-lock.json

What is the proper way to update an intermediary dependency with npm in the presence of the package-lock.json file ? 在存在package-lock.json文件的情况下,使用npm更新中间依赖项的正确方法是什么?

For example: 例如:

$ npm outdated --depth=1 eslint
Package  Current  Wanted  Latest  Location
eslint     4.9.0  4.10.0  4.10.0  MyApplication1 > grunt-eslint

The package-lock.json is doing its job by keeping eslint (an intermediary dependency, in this case for grunt-eslint) at 4.9.0. package-lock.json通过在4.9.0保持eslint(中间依赖,在本例中为grunt-eslint)来完成它的工作。 How do I update to eslint@4.10? 我如何更新到eslint@4.10?

I have tried the following commands but npm doesn't do anything: 我尝试了以下命令但是npm没有做任何事情:

npm update grunt-eslint --dev --depth 1
npm update eslint --dev

It works if I add eslint as a top-level dependency but I don't think that is the correct way to do this. 如果我将eslint添加为顶级依赖项,它可以工作,但我不认为这是正确的方法。

This is clearly a hacky workaround but it serves the purpose: 这显然是一个hacky解决方法,但它的目的是:

npm install eslint --save-dev && npm uninstall eslint --save-dev

I'll be happy to accept another answer if there is a better method of doing this. 如果有更好的方法,我会很乐意接受另一个答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM