Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
fix-peer-deps
Advanced tools
A modern CLI tool to analyze and fix peer dependency issues across multiple package managers
A modern CLI tool to analyze and fix peer dependency issues across multiple package managers (npm, yarn, pnpm, bun).
fix-peer-deps
is a powerful command-line tool designed to simplify the often complex task of managing peer dependencies in JavaScript/Node.js projects. It addresses common challenges developers face when working with packages that have peer dependency requirements:
The tool performs a deep analysis of your project's dependency tree by:
--fix
optionYou can try fix-peer-deps directly in your browser using RunKit:
// Interactive demo of fix-peer-deps features
const { analyzePeerDependencies, detectPackageManager, autoFix, checkDeepPeerDependencies } = require('fix-peer-deps');
// Sample project with various dependency scenarios
const project = {
dependencies: {
"react": "17.0.2",
"react-dom": "18.2.0",
"@mui/material": "5.15.5",
"@mui/lab": "5.0.0-alpha.161"
}
};
// Sample dependency info for deep checking
const depInfo = {
"@mui/lab": {
version: "5.0.0-alpha.161",
peerDependencies: {
"@mui/material": "^5.0.0",
"react": "^17.0.0 || ^18.0.0"
}
}
};
// Demonstrate key features
async function demonstrateFeatures() {
try {
// 1. Detect Package Manager
const packageManager = await detectPackageManager();
console.log('📦 Package Manager:', packageManager);
// 2. Analyze Dependencies
const issues = await analyzePeerDependencies();
console.log('\n🔍 Analysis Results:');
console.log('• Critical Issues:', issues.critical.length);
console.log('• Optional Issues:', issues.optional.length);
// 3. Check Deep Dependencies
const visited = new Set();
const deepIssues = await checkDeepPeerDependencies(
'@mui/lab',
depInfo['@mui/lab'],
depInfo,
visited
);
console.log('\n🌳 Deep Dependencies:');
deepIssues.forEach(issue =>
console.log(`• ${issue.package} → ${issue.dependency}`)
);
// 4. Get Auto-Fix Commands
const fixCommands = await autoFix();
console.log('\n🛠️ Suggested Fixes:');
fixCommands.forEach(cmd => console.log('•', cmd));
} catch (error) {
console.error('❌ Error:', error.message);
}
}
demonstrateFeatures();
The example above demonstrates:
Try it yourself by clicking the RunKit badge above!
# Using npm
npx fix-peer-deps
# Using yarn
yarn dlx fix-peer-deps
# Using pnpm
pnpm dlx fix-peer-deps
# Using bun
bunx fix-peer-deps
If you frequently work with multiple Node.js projects, you can install the package globally:
# Using npm
npm install -g fix-peer-deps
# Using yarn
yarn global add fix-peer-deps
# Using pnpm
pnpm add -g fix-peer-deps
# Using bun
bun add -g fix-peer-deps
After global installation:
Verify the installation:
fix-peer-deps --version
You can now run the tool from any directory:
cd /path/to/your/project
fix-peer-deps
Navigate to your project directory:
cd /path/to/your/project
Run the analysis:
fix-peer-deps
Review the output:
Fix issues either:
--fix
option# Analyze and get suggestions
fix-peer-deps
# Automatically fix issues
fix-peer-deps --fix
# Show help information
fix-peer-deps --help
# Check version
fix-peer-deps -v
# or
fix-peer-deps --version
fix-peer-deps
: Analyzes your project and provides suggestionsfix-peer-deps --fix
: Automatically installs missing peer dependenciesfix-peer-deps -h, --help
: Shows help informationfix-peer-deps -v, --version
: Shows the current versionThe tool will:
The tool categorizes peer dependency issues into two types:
--fix
optionWhen you run fix-peer-deps
, you'll see output similar to this:
🔍 Detecting package manager... npm
📦 Analyzing dependencies...
████████████████████████████████████ 100%
📋 Found Issues:
• 2 critical issues
• 1 optional issue
🚨 Critical Issues:
react-dom requires react@^18.2.0
Current: 17.0.2
@mui/material requires react@^17.0.0 || ^18.0.0
Current: missing
⚠️ Optional Issues:
@types/react optionally requires react@*
Current: 17.0.2
📝 Suggested Actions:
Run the following commands to resolve critical issues:
npm install react@18.2.0
npm install @mui/material
💡 Tips:
• Use --fix to automatically resolve critical issues
• Optional issues can be resolved manually if needed
This output shows:
Starting a New Project:
cd my-new-project
npm init -y
npm install some-package
fix-peer-deps # Check for any peer dependencies
Fixing Dependency Issues:
fix-peer-deps --fix # Automatically install missing dependencies
Auditing Dependencies:
fix-peer-deps # Review all peer dependency relationships
CI/CD Integration:
# In your CI script
fix-peer-deps || exit 1 # Exit with error if critical issues found
The tool automatically detects your package manager based on:
packageManager
field in package.jsonCommand Not Found
# Reinstall globally
npm install -g fix-peer-deps
Permission Errors
# Use sudo for global installation if needed
sudo npm install -g fix-peer-deps
Package Manager Detection Issues
# Ensure you're in a directory with package.json
ls package.json
These enhancements will help:
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © Sudeepta Sarkar
Sudeepta Sarkar sudsarkar13@gmail.com
If you encounter any problems or have suggestions for improvements, please file an issue at: https://github.com/sudsarkar13/packages/issues
FAQs
A modern CLI tool to analyze and fix peer dependency issues across multiple package managers
We found that fix-peer-deps demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.