2

I wanted to know if there is any clean way of preventing package.json file from updating to latest versions of the dependencies that it contains.

The reason I don't want them to update is because of I need to frequently run few scripts with certain libraries the project contains and if the libraries get updated to latest versions, then I may not be able to validate my tests if some additional transitive dependencies are present.

Please note: I am not using npm update in any case, but I do use npm install.

user9683713
  • 185
  • 2
  • 13
  • You mean that was `package-lock.json` does/is for ? npm install does not update any package. It just does what the name say, its install a new package. – Marc Dec 15 '21 at 10:47
  • Make sure to include version of the packages in the package.json. Also when you `npm install @1.2.3 --save` make sure to include the version. It should not update automaticaly when the version is specified. – Molda Dec 15 '21 at 10:59
  • 1
    Does this answer your question? [npm install the exact package version specified in package.json](https://stackoverflow.com/questions/41003470/npm-install-the-exact-package-version-specified-in-package-json) – StephanB Dec 15 '21 at 11:47
  • @Stebeber Yes, it's working now as expected. Thank you so much. – user9683713 Dec 16 '21 at 11:02

1 Answers1

2

See this answer: https://stackoverflow.com/a/41003507/4236831

You can specify the exact version in your package.json file.

A more detailed overview of managing the versions of your dependencies can be found here: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies

StephanB
  • 315
  • 2
  • 17