← All recipes
Moderne licensed

Upgrade transitive npm dependency

Recipe IDorg.openrewrite.javascript.UpgradeTransitiveDependencyVersion
Artifactorg.openrewrite:rewrite-javascript

Pins or upgrades a transitive npm dependency by adding an override entry to package.json and regenerating the lock file. For npm and Bun, adds to the overrides field; for Yarn, adds to resolutions; for pnpm, adds to pnpm.overrides. The override is idempotent — if the entry already exists with the same version, no change is made. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.

Single recipeMSAL

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.javascript.UpgradeTransitiveDependencyVersion --recipe-option "packageName=lodash" --recipe-option "newVersion=^5.0.0"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite:rewrite-javascript:8.88.0

Options

NameTypeDescription
packageNamerequiredStringThe name of the transitive npm dependency to upgrade.
e.g. lodash
newVersionrequiredStringThe version constraint to set on the override entry.
e.g. ^5.0.0
dependencyPathStringOptional dependency path (pnpm-style a>b>c or yarn-style a/b/c) to scope the override. When omitted, applies as a global override.
e.g. express>accepts

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats