dependency-conflict-resolver
Use this skill when resolving dependency conflicts. Activate when the user has package version conflicts, npm/yarn/pnpm install failures, peer dependency warnings, duplicate packages, or module resolution errors.
What this skill does
# Dependency Conflict Resolver Untangle and resolve package dependency conflicts. ## When to Use - Package installation fails - Peer dependency warnings - "Module not found" errors - Duplicate package warnings - Version mismatch errors - Lock file conflicts ## Common Error Types ### 1. Peer Dependency Conflicts ``` npm WARN ERESOLVE unable to resolve dependency tree npm WARN peer react@"^17.0.0" from [email protected] npm WARN peer react@"^18.0.0" from [email protected] ``` **Cause:** Two packages require different versions of the same peer dependency. ### 2. Version Conflicts ``` npm ERR! Could not resolve dependency: npm ERR! peer typescript@">=4.0 <5.0" from [email protected] npm ERR! node_modules/some-package npm ERR! some-package@"^1.0.0" from the root project ``` **Cause:** Package requires a version range you're not using. ### 3. Duplicate Packages ``` warning "package-a" has unmet peer dependency "lodash@^4.0.0". warning "package-b" has incorrect peer dependency "lodash@^3.0.0". ``` **Cause:** Multiple versions of the same package installed. ## Diagnostic Commands ### NPM ```bash # See dependency tree npm ls # Find specific package npm ls react # Find why package is installed npm why lodash # Check for outdated packages npm outdated # Audit for issues npm audit ``` ### Yarn ```bash # See dependency tree yarn list # Find specific package yarn why react # Check for duplicates yarn dedupe --check # Interactive upgrade yarn upgrade-interactive ``` ### PNPM ```bash # See dependency tree pnpm ls # Find specific package pnpm why react # List all versions of a package pnpm ls --depth Infinity | grep lodash ``` ## Resolution Strategies ### Strategy 1: Update to Compatible Versions ```bash # Find what versions are needed npm ls react --all # Update packages that need newer version npm update package-a package-b # Or install specific compatible version npm install [email protected] ``` ### Strategy 2: Override/Resolution **NPM (package.json):** ```json { "overrides": { "react": "18.2.0", "package-a": { "lodash": "4.17.21" } } } ``` **Yarn (package.json):** ```json { "resolutions": { "react": "18.2.0", "**/lodash": "4.17.21" } } ``` **PNPM (package.json):** ```json { "pnpm": { "overrides": { "react": "18.2.0", "lodash@^3.0.0": "4.17.21" } } } ``` ### Strategy 3: Force Install (Last Resort) ```bash # NPM - force through conflicts npm install --legacy-peer-deps # Or with force flag npm install --force # Yarn yarn install --ignore-peer-deps ``` **Warning:** This can lead to runtime errors. Use only when you've verified compatibility. ### Strategy 4: Deduplicate ```bash # NPM npm dedupe # Yarn yarn dedupe # PNPM (automatic, but can force) pnpm install ``` ## Debugging Deep Conflicts ### Trace the Dependency Chain ```bash # NPM - full tree npm ls --all > deps.txt # Find the conflict path grep -B5 "lodash@3" deps.txt ``` **Example output:** ``` ├─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] <- Conflict source ``` ### Check Package Requirements ```bash # View package.json of installed package cat node_modules/package-name/package.json | jq '.peerDependencies' # Or use npm view npm view package-name peerDependencies ``` ## Common Scenarios ### Scenario 1: React Version Mismatch ``` npm WARN [email protected] requires react@^18.2.0, but [email protected] is installed ``` **Solution:** ```bash # Upgrade React npm install react@18 react-dom@18 # Or if you need React 17 npm install react-dom@17 ``` ### Scenario 2: TypeScript Version ``` error TS2307: Cannot find module '@types/node' or its corresponding type declarations. ``` **Solution:** ```bash # Check TypeScript version npx tsc --version # Install compatible types npm install -D @types/node@ts$(npx tsc --version | cut -d' ' -f2 | cut -d'.' -f1-2) # Or specific version npm install -D @types/node@20 ``` ### Scenario 3: Native Module Rebuild ``` npm ERR! node-pre-gyp ERR! build error ``` **Solution:** ```bash # Rebuild native modules npm rebuild # Or for specific package npm rebuild bcrypt # Clear cache and reinstall rm -rf node_modules package-lock.json npm install ``` ### Scenario 4: Workspace Conflicts (Monorepo) ``` error Workspaces can only be enabled in private projects. ``` **Solution in package.json:** ```json { "private": true, "workspaces": [ "packages/*" ] } ``` ## Lock File Conflicts ### Git Merge Conflicts in Lock Files ```bash # Don't manually resolve - regenerate git checkout --theirs package-lock.json npm install # Or rm package-lock.json npm install ``` ### Lock File Out of Sync ```bash # NPM rm package-lock.json npm install # Yarn rm yarn.lock yarn install # PNPM rm pnpm-lock.yaml pnpm install ``` ## Prevention ### Pin Versions ```json { "dependencies": { "lodash": "4.17.21", // Exact version "react": "^18.2.0", // Minor updates OK "express": "~4.18.0" // Patch updates only } } ``` ### Use Lock Files ```bash # Always commit lock files git add package-lock.json # or yarn.lock, pnpm-lock.yaml # CI should use ci command npm ci # instead of npm install ``` ### Regular Updates ```bash # Check for updates regularly npm outdated # Update incrementally npm update # Use tools like renovate/dependabot ``` ## AI-Assisted Resolution ```markdown Help me resolve this dependency conflict: **Error message:** ``` [paste full error] ``` **Current package.json dependencies:** ```json [paste dependencies] ``` **What I've tried:** - [list attempts] Please: 1. Explain what's conflicting 2. Show the dependency chain causing it 3. Suggest the safest resolution 4. Note any potential runtime issues ``` ## Best Practices 1. **Read the full error** - It usually tells you what's wrong 2. **Check compatibility** - Before installing new packages 3. **Use lock files** - For reproducible installs 4. **Update regularly** - Small updates are easier than big jumps 5. **Test after resolving** - Conflicts can cause runtime issues 6. **Document workarounds** - Future you will thank you 7. **Avoid force** - Unless you understand the consequences
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.