0

I want to update a dependency (packageX) without changing a locked dependency of that package, (packageY). In my package-lock.json, I have:

"packageX": { "requires": { "packageY": "1.0.0", } },

Each time I do "npm install packageX," I'd like to update packageX but have packageY stay on the defined version. How can I do that?

wcjord
  • 499
  • 3
  • 14

1 Answers1

1

There is no way to do this, may be this link can explain better https://dev.to/saurabhdaware/but-what-the-hell-is-package-lock-json-b04

The story about package.json vs package-lock.json is tricky: npm install does not ignore package.json versions, nor does it ignore the package-lock.json. What it does is verify that the package.json and package-lock.json correspond to each other. That is, if the semver versions described in package.json fit with the locked versions in package-lock.json, npm install will use the latter completely, just like npm ci would.

Now, if you change package.json such that the versions in package-lock.json are no longer valid, your npm install will be treated as if you'd done npm install some-pkg@x.y.z, where x.y.z is the new version in the package.json for some-package.

parveen
  • 557
  • 3
  • 13