Install Peers CLI
install-peers-cli is a command-line interface (CLI) tool designed to manage and install a project's `peerDependencies` without unintended side effects. Currently at stable version 2.2.0, it supports both `npm` and `yarn` package managers, including `yarn workspaces`. A key differentiator is its "pure" approach: it installs peer dependencies without modifying the project's `package.json` file or updating lock files (like `package-lock.json` or `yarn.lock`). This ensures a clean development environment and predictable dependency resolution, allowing developers to manage peer dependencies manually or through CI/CD pipelines without altering the project's core dependency manifests. The release cadence appears irregular, driven by contributions and specific feature needs, rather than a fixed schedule.
Common errors
-
install-peers: command not found
cause The `install-peers` executable is not in your system's PATH, typically because it's a locally installed `devDependency`.fixUse `npm run install-peers` (if configured in `package.json` scripts) or `npx install-peers-cli`. -
npm ERR! Failed at the my-package@1.0.0 install-peers script.
cause An error occurred during the execution of the `install-peers` script defined in your `package.json`.fixCheck the output immediately preceding this error for more specific details from `install-peers-cli` (e.g., dependency resolution issues, network problems). -
'install-peers' is not recognized as an internal or external command, operable program or batch file.
cause This is the Windows equivalent of 'command not found', indicating the executable is not accessible from your current shell.fixEnsure `install-peers-cli` is installed as a `devDependency` and run it using `npm run install-peers` or `npx install-peers-cli`.
Warnings
- gotcha Despite using `install-peers-cli`, you may still encounter 'unmet peer dependency' warnings during a regular `npm install` or `yarn install`. This is expected behavior as this CLI runs after the main installation phase and doesn't modify how package managers initially process `peerDependencies`.
- gotcha `install-peers-cli` does not perform version resolution or compatibility checks for peer dependencies. It simply attempts to install the specified versions. It is the developer's responsibility to ensure that the declared `peerDependencies` are compatible with the consuming project's direct dependencies.
- gotcha Executing `install-peers` directly from the command line without `npm run` or `npx` may result in a 'command not found' error if `install-peers-cli` is only installed locally and not in your system's PATH.
Install
-
npm install install-peers-cli -
yarn add install-peers-cli -
pnpm add install-peers-cli
Imports
- install-peers command
import { installPeers } from 'install-peers-cli'npx install-peers-cli
- package.json script integration
npm install install-peers-cli && install-peers
{ "scripts": { "install-peers": "install-peers" } } - Direct local execution
install-peers
./node_modules/.bin/install-peers
Quickstart
{
"name": "my-project",
"version": "1.0.0",
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
},
"scripts": {
"install-peers": "install-peers"
},
"devDependencies": {
"install-peers-cli": "^2.2.0"
}
}
// Install the CLI tool as a devDependency
$ npm install --save-dev install-peers-cli
// Then, run the script to install peer dependencies
$ npm run install-peers
// or using yarn
$ yarn add --dev install-peers-cli
$ yarn install-peers