Gathering detailed insights and metrics for peer-dep-helper
Gathering detailed insights and metrics for peer-dep-helper
Gathering detailed insights and metrics for peer-dep-helper
Gathering detailed insights and metrics for peer-dep-helper
npm install peer-dep-helper
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
peer-dep-helper
is a powerful Command Line Interface (CLI) tool designed to streamline the management of peer dependencies in Node.js projects. It helps developers detect, audit, and automatically fix common issues related to peer dependencies, ensuring project stability and preventing unexpected runtime errors.
node_modules
and package.json
to identify missing or mismatched peer dependencies..peer-dep-helperrc
file.strict
, compatible
, latest
) to suit various project needs.To install peer-dep-helper
globally, use your preferred package manager:
1npm install -g peer-dep-helper 2# OR 3yarn global add peer-dep-helper 4# OR 5pnpm add -g peer-dep-helper
The peer-dep-helper
tool provides two main commands: audit
and fix
.
peer-dep-helper audit
Scans your project for peer dependency issues and prints a detailed report. This is the default command if no other command is specified.
peer-dep-helper fix
Detects peer dependency issues and attempts to automatically install or suggest the correct versions.
These options can be used with any command.
--json
: Output the report as JSON.
peer-dep-helper audit --json
--silent
: Suppress all terminal output except errors.
peer-dep-helper audit --silent
--cwd <path>
: Specify a custom working directory for the scan. Defaults to the current working directory.
peer-dep-helper audit --cwd ./my-project
--strategy <strategy>
: Define the version resolution strategy.
strict
, compatible
(default), latest
.peer-dep-helper audit --strategy strict
--dry-run
: (Applicable to fix
command) Show what would be installed/changed without making any actual modifications.
peer-dep-helper fix --dry-run
--fail-on-issues
: Exit with a non-zero code if issues are found. Useful for CI/CD pipelines.
peer-dep-helper audit --fail-on-issues
--fix
: Automatically apply fixes after auditing. This is a convenience flag for the audit
command that triggers the fix
logic.
peer-dep-helper audit --fix
--write
: Write fixed dependencies to the root package.json
file.
peer-dep-helper fix --write
--only <packages...>
: Fix only specified packages. Provide a comma-separated list of package names.
peer-dep-helper fix --only react,react-dom
peer-dep-helper
can be configured using a .peer-dep-helperrc
file (JSON or YAML format) in your project's root directory. CLI flags will always override settings from the configuration file.
The following configuration options are available:
cwd
: Specify a custom working directory for the scan. Defaults to the current working directory.ignore
: Specify an array of packages to ignore during the scan.Example .peer-dep-helperrc.json
:
1{ 2 "strategy": "strict", 3 "silent": false, 4 "ignore": [ 5 "some-package-to-ignore", 6 "another-package-to-ignore" 7 ] 8}
Note: The ignore
option is mentioned in bin/index.js
but not explicitly defined in PLAN.md
or REFINEMENT_PLAN.md
as a configurable option. Its behavior should be clarified.
The tool operates by:
.peer-dep-helperrc
.package.json
and recursively scans the node_modules
directory to identify all installed packages and their declared peerDependencies
.peerDependency
, it checks if the required peer is:
node_modules
.missing
or version_mismatch
.--strategy
.fix
command or --fix
flag is used, it constructs and executes appropriate package manager commands (npm install
, yarn add
, pnpm add
) to resolve the issues. It can optionally update the root package.json
.The --strategy
option dictates how peer-dep-helper
resolves required peer dependency versions.
compatible
(Default): Aims to find a version that satisfies all declared peer dependency ranges. If multiple ranges exist for the same peer, it attempts to find the broadest compatible version.strict
: Requires that the installed peer dependency exactly matches the version specified by the peer dependency range. This strategy is less forgiving and will flag more issues.latest
: Attempts to resolve the peer dependency to its latest available version that still satisfies the declared range. (Further refinement needed: Currently, this might rely on locally installed versions or require network calls, which are generally out of scope for this tool's current design. Its exact behavior should be clarified and documented.)peer-dep-helper
utilizes a caching mechanism to speed up repeated scans. Analysis results are stored in a .peer-dep-helper-cache.json
file.
package.json
and lock files. See lib/scan.js documentation for details..peer-dep-helper-cache.json
in your project root. (A CLI option for clearing cache may be added in the future.)The tool is being developed with monorepo environments in mind. It aims to:
package.json
files: Ensure all relevant package.json
files within a monorepo are scanned for peer dependencies.pnpm-workspace.yaml
for accurate workspace path determination.The project uses jest
for comprehensive testing. See Testing Documentation.
scan.js
, fix.js
, utils.js
, config.js
, output.js
).fixtures/
directory containing various test projects to simulate real-world scenarios (e.g., projects with missing peers, version mismatches, no issues, monorepo examples). See Fixtures Documentation.fs/promises
and execa
are mocked to prevent actual file system changes or command executions during tests.See CONTRIBUTING.md for guidelines on setting up the development environment, running tests, and submitting pull requests.
peer-dep-helper
is installed globally and your system's PATH includes the global npm/yarn/pnpm bin directory.--silent
removed to see debug logs..peer-dep-helper-cache.json
to clear the cache.This project is licensed under the MIT License. See the package/license
file for details.
Made with ❤️ by Teck
No vulnerabilities found.
No security vulnerabilities found.