enhanced-peer-deps
Version:
Enhanced peer dependency resolution for npm, yarn, and pnpm
171 lines (106 loc) ⢠5.31 kB
Markdown
# Enhanced Peer Dependencies (epd)
[](https://www.npmjs.com/package/enhanced-peer-deps)
[](https://opensource.org/licenses/MIT)
A smart CLI tool that intelligently resolves peer dependency conflicts across npm, yarn, and pnpm projects.
## š Features
- **Intelligent Resolution**: Automatically finds the best version that satisfies the most peer dependency requirements
- **Multi-Package Manager Support**: Works with npm, yarn, and pnpm
- **Workspace Aware**: Handles monorepo structures with multiple packages
- **Registry Integration**: Queries npm registry for available versions
- **Detailed Reporting**: Shows conflicts and resolution strategies
- **Non-Destructive**: Preserves your original package.json
- **Zero Configuration**: Works out of the box
## š¦ Installation
```bash
# Install globally
npm install -g enhanced-peer-deps
# Or with yarn
yarn global add enhanced-peer-deps
# Or with pnpm
pnpm add -g enhanced-peer-deps
## š Usage
Use `epd` as a drop-in replacement for your package manager's install command:
### Installing Dependencies from package.json
```shellscript
# Install all dependencies from package.json
epd install
# Or simply
epd
```
### Adding New Packages
```shellscript
# Add a new package
epd add react
# Add multiple packages
epd add react react-dom
# Add with specific version
epd add react@18.2.0
```
### Specifying Package Manager
By default, epd automatically detects your package manager based on lockfiles or availability. You can override this with the `--pm` flag:
```shellscript
# Force using npm
epd install --pm=npm
# Force using yarn
epd add react --pm=yarn
# Force using pnpm
epd add react --pm=pnpm
```
## š How It Works
When you run `epd`, it:
1. **Analyzes** your project structure and detects workspaces
2. **Collects** all peer dependencies from all packages
3. **Resolves** version conflicts using a sophisticated algorithm:
1. First tries to find a version that satisfies all requirements
2. If none exists, queries the npm registry for available versions
3. Selects the version that satisfies the most requirements
4. **Creates** a temporary package.json with the resolved dependencies
5. **Installs** packages using your preferred package manager
6. **Restores** your original package.json
## š ļø Command Line Options
| Option | Description
|-----|-----
| `--pm=<manager>` | Force a specific package manager (npm, yarn, pnpm)
| `--debug` | Enable debug mode with verbose logging
## ā ļø Troubleshooting
### Package Manager Not Found
If you see an error like:
```plaintext
ā Forced package manager pnpm is not installed or not in PATH
```
Make sure the specified package manager is installed and available in your PATH.
### Registry Connection Issues
If you encounter registry connection problems:
```plaintext
ā Error fetching versions for react: HTTP error! Status: 404
```
Check your internet connection and ensure you have access to the npm registry. If you're using a custom registry, verify it's correctly configured in your npm settings.
### Command Not Found
If you see:
```plaintext
Command 'epd' not found
```
Ensure the package is properly installed globally. You may need to add the npm global bin directory to your PATH.
## š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## š License
This project is licensed under the MIT License - see the LICENSE file for details.
## š Acknowledgements
- Inspired by npm's `--legacy-peer-deps` flag
- Built with love for the JavaScript community
```plaintext
This README provides comprehensive documentation for the enhanced-peer-deps tool. It covers installation, usage examples for different package managers, features, command-line options, troubleshooting, and more. The document is structured with clear headings and includes emoji icons to make different sections visually distinct.
The README explains how the tool works under the hood and provides troubleshooting guidance for common issues users might encounter. It also includes contributing guidelines and license information to encourage community participation.
<Actions>
<Action name="Add CI/CD workflow" description="Create GitHub Actions workflow for automated testing and publishing" />
<Action name="Create dependency graph visualization" description="Add a feature to visualize the dependency graph" />
<Action name="Add configuration file support" description="Implement support for a .epdrc configuration file" />
<Action name="Write unit tests" description="Create comprehensive test suite for the tool" />
<Action name="Add TypeScript support" description="Convert the codebase to TypeScript for better type safety" />
</Actions>
```