Search code examples
node.jsnpmpackage-lock.jsonnpm-update

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?

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. How do I update to [email protected]?

I have tried the following commands but npm doesn't do anything:

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.


Solution

  • This is clearly a hacky workaround but it serves the purpose:

    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.