Find Node.js dependency
Recipe ID
org.openrewrite.javascript.dependencies.find-dependencyArtifact@openrewrite/rewriteFinds 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/rewriteOptions
| Name | Type | Description |
|---|---|---|
packageNamerequired | | The name of the npm package to find. Supports glob patterns. e.g. lodash |
version | | An exact version number or semver selector used to select the version number. Leave empty to match any version. e.g. ^18.0.0 |
onlyDirect | | If 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 |