node.jsnpmvue-cli-4

How to update a dependency within a dependency?


I would like to update a 'handlebars' node module that is a dependency of Vue-Cli (see screenshot).

enter image description here

What's the correct way to do this?

Thank you


Solution

  • Add a resolutions field to your package.json file and define your version overrides.

    It will look like this

    {
      ...
      "dependencies": {
        ...
      },
      "devDependencies": {
        ...
      },
      "resolutions": {
        "EXAMPLE_PACKAGE": "EXAMPLE_PACKAGE_NEEDED_VERSION"
      }
    }
    

    It shouldn't update the package in the dependency. But your application will use the needed version. It can be useful for example if some dependencies in your dependency have important security updates, and your dependency has not updated the version yet.