← All recipes
Moderne licensed

Find Node.js dependency

Recipe IDorg.openrewrite.javascript.dependencies.find-dependencyArtifact@openrewrite/rewrite

Finds dependencies in a project's package.json. Can find both direct dependencies and dependencies that transitively include the target package. This recipe is commonly used as a precondition for other recipes.

Single recipeMSAL

Usage

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

mod run . --recipe org.openrewrite.javascript.dependencies.find-dependency --recipe-option "packageName=lodash"

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

mod config recipes npm install @openrewrite/rewrite

Options

NameTypeDescription
packageNamerequiredThe name of the npm package to find. Supports glob patterns.
e.g. lodash
versionAn exact version number or semver selector used to select the version number. Leave empty to match any version.
e.g. ^18.0.0
onlyDirectIf true (default), only matches dependencies that directly match the package name. If false, also marks direct dependencies that have the target package as a transitive dependency.
e.g. true