Skip to main content
Bun supports npm’s "overrides" and Yarn’s "resolutions" in package.json. These let you pin the version of a metadependency — a dependency of one of your dependencies — regardless of what version is requested by the package that depends on it.

When to use overrides

Consider a project with one dependency, foo, which depends on bar:
After bun install, the resolved tree might be:
If bar@4.5.6 has a security vulnerability and the fix is in bar@4.4.2, you can force a specific version of bar across the entire dependency tree using overrides.

npm overrides

Add an "overrides" field to package.json:
Bun defers to the specified version range when resolving bar, whether it appears as a direct dependency or as a transitive dependency anywhere in the tree.
Bun currently supports only top-level "overrides". Nested overrides (scoping an override to a specific dependency path) are not supported.

Yarn resolutions

Yarn uses "resolutions" instead of "overrides". Bun supports this field to ease migration from Yarn.
As with "overrides", nested resolutions are not currently supported.

Forcing a direct dependency version

Overrides also work on your direct dependencies. This is useful when you want to lock a dependency to a specific patch version:

Patching packages

To apply local code modifications to an installed package, use bun patch:
This opens the package source in your editor. After making changes, finalize the patch:
The patch is stored in a patches/ directory and recorded in package.json under patchedDependencies. Bun automatically applies the patch on every install.