| name | dependency-resolver |
| description | Identify, analyze, and manage software dependencies before deployment. Use this skill when preparing applications for deployment, resolving dependency conflicts, updating dependencies, auditing security vulnerabilities, managing package versions, or troubleshooting dependency-related issues. Supports multiple package managers (npm, pip, maven, cargo, go mod, composer) and provides actionable recommendations for dependency management. |
Dependency Resolver
Analyze, manage, and resolve software dependencies to ensure safe and successful deployments. Identifies conflicts, security vulnerabilities, version mismatches, and missing dependencies.
Core Capabilities
1. Dependency Analysis
Examine project dependencies:
- Direct dependencies - Packages explicitly required
- Transitive dependencies - Dependencies of dependencies
- Dev dependencies - Development-only packages
- Peer dependencies - Required by packages but not auto-installed
- Optional dependencies - Non-critical packages
2. Conflict Detection
Identify dependency issues:
- Version conflicts - Multiple versions of same package
- Missing dependencies - Required but not installed
- Incompatible versions - Version constraints that can't be satisfied
- Circular dependencies - Packages depending on each other
- Platform incompatibility - OS or architecture mismatches
3. Security Auditing
Check for vulnerabilities:
- Known CVEs - Common Vulnerabilities and Exposures
- Outdated packages - Old versions with security patches available
- Malicious packages - Typosquatting or compromised packages
- License issues - Incompatible or restrictive licenses
4. Dependency Resolution
Provide solutions:
- Version pinning - Lock compatible versions
- Conflict resolution - Strategies to resolve version conflicts
- Dependency updates - Safe upgrade paths
- Alternative packages - Replacement suggestions
- Minimal installations - Remove unnecessary dependencies
Dependency Resolution Workflow
Step 1: Identify Package Manager
Detect which dependency system is in use:
Package manager files:
npm/yarn: package.json, package-lock.json, yarn.lock
pip: requirements.txt, Pipfile, setup.py, pyproject.toml
maven: pom.xml
gradle: build.gradle, build.gradle.kts
cargo: Cargo.toml, Cargo.lock
go: go.mod, go.sum
composer: composer.json, composer.lock
bundler: Gemfile, Gemfile.lock
nuget: *.csproj, packages.config
Step 2: Parse Dependency Manifest
Read and understand dependency declarations:
npm (package.json):
{
"dependencies": {
"express": "^4.18.0",
"lodash": "~4.17.21"
},
"devDependencies": {
"jest": "^29.0.0"
},
"peerDependencies": {
"react": ">=16.0.0"
}
}
Python (requirements.txt):
django>=4.0,<5.0
requests==2.28.1
numpy>=1.20.0
pytest # No version specified
Maven (pom.xml):
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.23</version>
</dependency>
</dependencies>
Step 3: Analyze Dependency Tree
Build complete dependency graph:
my-app
├── express@4.18.2
│ ├── body-parser@1.20.1
│ │ └── bytes@3.1.2
│ ├── cookie@0.5.0
│ └── debug@2.6.9
│ └── ms@2.0.0
└── lodash@4.17.21
Check for:
- Multiple versions of same package
- Deeply nested dependencies
- Large dependency trees
- Unmaintained packages
Step 4: Detect Issues
Identify problems:
Version conflicts:
app requires:
- package-a@1.0.0 (depends on shared@^1.0.0)
- package-b@2.0.0 (depends on shared@^2.0.0)
Conflict: shared@1.x vs shared@2.x
Missing dependencies:
Error: Cannot find module 'missing-package'
Cause: Listed in package.json but not installed
Security vulnerabilities:
lodash@4.17.20 has known vulnerability CVE-2020-8203
Severity: High
Fix available: Upgrade to lodash@4.17.21
Step 5: Propose Solutions
Recommend fixes:
For version conflicts:
- Use compatible versions
- Update conflicting packages
- Use resolutions/overrides
- Consider alternatives
For missing dependencies:
- Install missing packages
- Add to manifest file
- Check for typos
For security issues:
- Update vulnerable packages
- Apply security patches
- Replace with secure alternatives
Dependency Management Patterns
Pattern 1: Version Conflict Resolution
Issue:
{
"dependencies": {
"package-a": "^1.0.0",
"package-b": "^2.0.0"
}
}
Analysis:
Dependency tree:
├── package-a@1.0.0
│ └── lodash@3.10.1
└── package-b@2.0.0
└── lodash@4.17.21
Conflict: Two versions of lodash (3.10.1 and 4.17.21)
Solution 1: Update package-a
{
"dependencies": {
"package-a": "^2.0.0",
"package-b": "^2.0.0"
}
}
Solution 2: Use resolutions (npm/yarn)
{
"dependencies": {
"package-a": "^1.0.0",
"package-b": "^2.0.0"
},
"resolutions": {
"lodash": "^4.17.21"
}
}
Solution 3: Find alternative
{
"dependencies": {
"alternative-package-a": "^1.0.0",
"package-b": "^2.0.0"
}
}
Pattern 2: Security Vulnerability Fix
Audit result:
$ npm audit
found 3 vulnerabilities (1 moderate, 2 high)
High: Prototype Pollution
Package: lodash
Dependency of: express
Path: express > lodash
More info: https://npmjs.com/advisories/1065
Solution:
npm audit fix
npm audit fix --force
npm install lodash@latest
Verify fix:
npm audit
Pattern 3: Missing Peer Dependency
Error:
npm WARN package-b@1.0.0 requires a peer of react@>=16.0.0 but none is installed.
Analysis:
{
"peerDependencies": {
"react": ">=16.0.0"
}
}
Solution:
npm install react@^18.0.0
Update package.json:
{
"dependencies": {
"react": "^18.0.0",
"package-b": "^1.0.0"
}
}
Pattern 4: Outdated Dependencies
Check for updates:
npm outdated
Package Current Wanted Latest Location
express 4.17.1 4.18.2 4.18.2 my-app
lodash 4.17.20 4.17.21 4.17.21 my-app
react 17.0.2 17.0.2 18.2.0 my-app
Analysis:
- Current: Installed version
- Wanted: Max version satisfying semver
- Latest: Newest version available
Solution strategy:
npm update
npm install react@latest
npm install express@4.18.2 --save-exact
Pattern 5: Circular Dependencies
Detection:
Circular dependency detected:
package-a → package-b → package-c → package-a
Analysis:
const b = require('./package-b');
const c = require('./package-c');
const a = require('./package-a');
Solution:
module.exports = { sharedFunction };
const shared = require('./package-shared');
const shared = require('./package-shared');
Pattern 6: Platform-Specific Dependencies
Issue:
{
"dependencies": {
"fsevents": "^2.3.2"
}
}
Error on Linux:
npm ERR! notsup Unsupported platform for fsevents@2.3.2
Solution:
{
"dependencies": {
"chokidar": "^3.5.3"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
}
}
Pattern 7: Dependency Bloat
Analysis:
npm ls --all --depth=0
du -sh node_modules/
Identify large packages:
npx cost-of-modules
┌────────────────────────┬───────────┬────────────┐
│ name │ size │ dependencies│
├────────────────────────┼───────────┼────────────┤
│ @babel/core │ 45 MB │ 234 │
│ webpack │ 38 MB │ 189 │
│ lodash │ 1.5 MB │ 0 │
└────────────────────────┴───────────┴────────────┘
Solutions:
{
"dependencies": {
"lodash.debounce": "^4.0.8",
"date-fns": "^2.29.3"
}
}
Version Constraint Syntax
npm/JavaScript (Semver)
^1.2.3 - Compatible with 1.2.3 (>=1.2.3 <2.0.0)
~1.2.3 - Approximately 1.2.3 (>=1.2.3 <1.3.0)
1.2.x - 1.2.0, 1.2.1, etc. (>=1.2.0 <1.3.0)
* - Any version
latest - Latest version
1.2.3 - Exact version
>=1.2.3 - Greater than or equal
<2.0.0 - Less than
1.2.3 - 2.3.4 - Range
Python (PEP 440)
==1.2.3 - Exact version
>=1.2.3 - Minimum version
>=1.2,<2.0 - Range
~=1.2.3 - Compatible release (>=1.2.3, ==1.2.*)
!=1.2.3 - Exclude version
package - Any version
Maven/Java
<version>1.2.3</version>
<version>[1.2.3]</version>
<version>[1.0,2.0)</version>
<version>[1.0,)</version>
<version>(,2.0)</version>
Cargo/Rust
[dependencies]
package = "1.2.3"
package = "^1.2.3"
package = "~1.2.3"
package = ">= 1.2.3"
package = "*"
Dependency Commands Reference
npm/yarn
npm install
yarn install
npm install package-name
yarn add package-name
npm install --save-dev package-name
yarn add --dev package-name
npm update
yarn upgrade
npm outdated
yarn outdated
npm audit
yarn audit
npm audit fix
yarn audit fix
npm ls
yarn list
npm prune
yarn autoclean
npm ci
yarn install --frozen-lockfile
Python (pip)
pip install -r requirements.txt
pip install package-name
pip install package-name==1.2.3
pip install --upgrade package-name
pip list
pip list --outdated
pip-audit
pip freeze > requirements.txt
pip uninstall package-name
Maven
mvn install
mvn versions:update-properties
mvn dependency:tree
mvn dependency:analyze
mvn versions:display-dependency-updates
mvn dependency-check:check
Go
go mod download
go get package-name
go get -u ./...
go mod tidy
go mod verify
go list -m all
go mod graph
go list -json -m all | nancy sleuth
Pre-Deployment Checklist
1. Dependency Installation
npm ci
echo $?
2. Security Audit
npm audit
npm audit fix
3. License Compliance
npx license-checker --summary
npx license-checker --excludeLicenses "GPL,AGPL"
4. Dependency Tree Analysis
npm dedupe
npm ls
npm ls --depth=5
5. Platform Compatibility
6. Lock File Consistency
git ls-files package-lock.json
npm ci
7. Size Check
du -sh node_modules/
npx cost-of-modules
npm prune --production
Common Issues and Solutions
Issue 1: "Cannot find module"
Error:
Error: Cannot find module 'express'
Causes:
- Dependency not installed
- Not listed in package.json
- Wrong import path
Solutions:
npm install express
npm install express --save
rm -rf node_modules
npm install
Issue 2: Version Conflict
Error:
npm ERR! peer dep missing: react@>=16.0.0
Solution:
npm info package-name peerDependencies
npm install react@^16.0.0
Issue 3: Lock File Out of Sync
Error:
npm ERR! package-lock.json lockfileVersion mismatch
Solution:
rm package-lock.json
npm install
nvm use 16
npm install
Issue 4: Network/Registry Errors
Error:
npm ERR! network timeout
Solution:
npm config set timeout 60000
npm config set registry https://registry.npmjs.org/
npm cache clean --force
Issue 5: Post-Install Script Failures
Error:
npm ERR! postinstall script failed
Solution:
node --version
npm --version
npm install -g node-gyp
sudo apt-get install build-essential python3
Best Practices
- Use lock files - Commit package-lock.json, yarn.lock, Cargo.lock
- Pin major versions - Avoid wildcards in production
- Regular updates - Keep dependencies current, not cutting-edge
- Security audits - Run before every deployment
- Minimal dependencies - Only include what you need
- Review licenses - Ensure compatibility with your project
- Test after updates - Run full test suite
- Document decisions - Note why specific versions are used
- Use semantic versioning - Understand version implications
- Monitor size - Keep bundle size reasonable
Ecosystem-Specific Guides
For detailed ecosystem-specific information: