Search code examples
javascriptnpmnpm-installyarnpkg

Is it possible to specify a npm module version without updating package.json?


I would like to override a npm module's version without changing the package.json file as I would like to avoid forking the repo, if possible.

If the package.json file looks something like

    ...
    "dependencies": {
        "iwanttooverridethis": "2.5.0",
        ...

can I run a step like npm install --override "iwanttooverridethis=3.0.0" which would install version 3.0.0 of iwanttooverridethis instead of version 2.5.0? Or achieve the same result some other way?


Solution

  • You should be able to use the --no-save flag to install the specified npm package version without changing the package.json file. Just keep in mind that this is temporary and will reset to the one specified in the package.json file when you run npm install. An example is npm install yourpackage@3.0.0 --no-save.