In JavaScript
Last updated: Sep 30, 2026
A transitive dependency (also called an indirect dependency) is a package that your project does not use directly. One of your direct or intermediate dependencies needs it.
Try the strategies below in this sequence. Move to the next strategy only if the previous one does not correct the problem.
Identify the dependency chain
For strategies 2 and 3, find the direct or intermediate dependency that pulls in the vulnerable package. Use your package manager:
npm explain <package>Strategy 1: Update the transitive dependency
The first and simplest method is to update the vulnerable dependency directly.
npm update <package>This works when the semver ranges of the direct or intermediate dependencies let you install a version with the security patch. But a direct or intermediate dependency can pin the transitive dependency to a vulnerable version, or to a range that excludes the patched release. If it does, this command does not update it.
Strategy 2: Update the direct or intermediate dependency
If strategy 1 did not update the transitive dependency, a direct or intermediate dependency probably constrains its version. Update that dependency:
npm update <direct-or-intermediate-package>This can pull in a newer version of the transitive dependency with the security fix. But the direct dependency can be at its latest version and continue to use the vulnerable transitive package. If it does, this strategy also does not correct the problem.
Strategy 3: Use dependency overrides
When the semver ranges in the dependency tree block the patched version, force a safe version with an override.
Add this to your package.json:
"overrides": {
"<package>": "<safe-version>"
}Overrides bypass the version resolution logic of the package manager. They can cause incompatibilities. Before you merge, run all tests and linters locally. Make sure that the CI pipeline passes. If something breaks, move to strategy 4.
Strategy 4: Wait for an installable version
At this point, the fix is out of your hands. Two causes can prevent the installation of a patched version.
A release-age policy holds the fix
Supply chain hardening frequently blocks packages published too recently.
In pnpm,
this is the minimumReleaseAge setting of pnpm-workspace.yaml.
Other setups enforce it through a registry proxy or an organization policy.
When a patched version exists but is younger than the threshold,
the fix lands on its own after the window.
Do not lower the threshold. Do not use an override to remove the wait. These two actions defeat the control that protects you from a release compromised minutes after its publication.
Upstream has no patched version
The upstream project did not publish a patched version. Two releases are necessary:
- The maintainers of the vulnerable package publish a patched version.
- The maintainers of the direct or intermediate dependency release a new version that adopts the patched transitive dependency.
This procedure can continue for days or longer. In the meantime, you can accept the risk through your vulnerability management workflow. Monitor the upstream project. Update when a safe version is available.
One more strategy: Fork and remove shrinkwrap
Sometimes,
a library ships with an
npm-shrinkwrap.json
file.
This file locks its dependency tree,
and overrides have no effect.
To correct this problem, fork the library. Remove the shrinkwrap file. Then point to your fork until upstream corrects the problem. This method has the highest cost in work and maintenance. Use it only when no other strategy works.
This applies to npm only. pnpm ignores npm-shrinkwrap.json and
package-lock.json. It resolves from its own lockfile and does not honor a
shrinkwrap from a dependency. The override of strategy 3 takes effect in all
cases. Thus, a fork is not necessary.