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 [email protected]
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" }
This packages modifies package-lock. json to force the installation of specific version of a transitive dependency (dependency of dependency), similar to yarn's selective dependency resolutions, but without having to migrate to yarn.
A resolution tells yarn to use a specific version of a package globally, regardless of what version is referenced within the applications package.json or any sub-packages package.json . If you encounter package mismatches, this trick can save you a lot of time.
Speed and Performance As mentioned above, while NPM installs dependency packages sequentially, Yarn installs in-parallel. Because of this, Yarn performs faster than NPM when installing larger files.
Yarn supports selective version resolutions, which lets you define custom package versions or ranges inside your dependencies through the resolutions field in your package. json file. Normally, this would require manual edits in the yarn.
This does not seem to be supported by npm natively, however this package aims to add this functionality:
https://github.com/rogeriochaves/npm-force-resolutions
npm is due to support overrides
, which is equivalent to yarn's resolutions
.
For more information about the current RFC status:
https://github.com/npm/rfcs/blob/latest/accepted/0036-overrides.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With