Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm equivalent of yarn resolutions?

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" } 
like image 289
adanilev Avatar asked Sep 20 '18 01:09

adanilev


People also ask

What is resolutions npm?

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.

What is yarn resolution?

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.

Is npm as fast as yarn?

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.

What is the use of resolutions in package json?

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.


2 Answers

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

like image 138
Julien Avatar answered Sep 22 '22 09:09

Julien


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

like image 21
Gajus Avatar answered Sep 19 '22 09:09

Gajus