Is there an npm
equivalent of the yarn resolutions functionality? There is no mention of it in the npm package.json docs.
For example, I want to install lerna@3.3.2
and one of its dependencies (@lerna/publish) at 3.3.2 as well. Currently doing that with yarn
like so, but would prefer to use npm and not manually change package-lock.json
or anything dodgy like that.
"devDependencies": {
"lerna": "3.3.2",
},
"resolutions": {
"@lerna/publish": "3.3.2"
}
Since NPM 8.3 the equivalent to yarn resolutions is called overrides.
To make sure the package foo is always installed as version 1.0.0 no matter what version your dependencies rely on:
{
"overrides": {
"foo": "1.0.0"
}
}
Documentation: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides
Why and how the feature was added it's discussed in the RFC and discussion on the topic was indexed on this github issue