"overrides"
and Yarn’s "resolutions"
in package.json
. These are mechanisms for specifying a version range for metadependencies—the dependencies of your dependencies.
package.json
package.json
. Let’s say you have a project with one dependency, foo
, which in turn has a dependency on bar
. This means bar
is a metadependency of our project.
package.json
bun install
, Bun will install the latest versions of each package.
tree layout of node_modules
bar@4.5.6
? We may want a way to pin bar
to an older version that doesn’t have the vulnerability. This is where "overrides"
/"resolutions"
come in.
"overrides"
Add bar
to the "overrides"
field in package.json
. Bun will defer to the specified version range when determining which version of bar
to install, whether it’s a dependency or a metadependency.
Bun currently only supports top-level
"overrides"
. Nested
overrides are not
supported.package.json
"resolutions"
The syntax is similar for "resolutions"
, which is Yarn’s alternative to "overrides"
. Bun supports this feature to make migration from Yarn easier.
As with "overrides"
, nested resolutions are not currently supported.
package.json