ln-711-npm-upgrader
Type: L3 Worker
Category: 7XX Project Bootstrap
Parent: ln-710-dependency-upgrader
Upgrades Node.js dependencies using npm, yarn, or pnpm with automatic breaking change detection and migration.
Overview
| Aspect |
Details |
| Input |
Project path, package manager type |
| Output |
Updated package.json, lock file, migration report |
| Supports |
npm, yarn (classic & berry), pnpm |
Workflow
See diagram.html for visual workflow.
Phases: Pre-flight → Analyze → Security Audit → Check Outdated → Identify Breaking → Apply Upgrades → Apply Migrations → Verify Build → Report
Phase 0: Pre-flight Checks
| Check |
Required |
Action if Missing |
| Lock file (package-lock.json, yarn.lock, pnpm-lock.yaml) |
Yes |
Warn and run npm install first |
| package.json |
Yes |
Block upgrade |
Workers assume coordinator (ln-710) already verified git state and created backup.
Phase 1: Analyze Dependencies
Read package.json and categorize dependencies for upgrade priority.
Dependency Categories
| Category |
Examples |
Priority |
| framework |
react, vue, angular |
2 (after peer deps) |
| build |
vite, webpack, esbuild |
3 |
| ui |
@radix-ui/*, tailwindcss |
4 |
| state |
@tanstack/react-query, zustand |
5 |
| utils |
lodash, date-fns |
6 |
| dev |
eslint, prettier, typescript |
7 |
| peer |
@types/*, typescript |
1 (first) |
Phase 2: Security Audit
Commands
| Manager |
Command |
| npm |
npm audit --audit-level=high |
| yarn |
yarn audit --level high |
| pnpm |
pnpm audit --audit-level high |
Actions
| Severity |
Action |
| Critical |
Block upgrade, report |
| High |
Warn, continue |
| Moderate/Low |
Log only |
Phase 3: Check Outdated
Commands
| Manager |
Command |
| npm |
npm outdated --json |
| yarn |
yarn outdated --json |
| pnpm |
pnpm outdated --json |
Phase 4: Identify Breaking Changes
Detection
- Compare current vs latest major versions
- Check breaking_changes_patterns.md
- Query Context7/Ref for migration guides
Common Breaking Changes
See breaking_changes_patterns.md for full patterns.
| Package |
Breaking Version |
Key Changes |
| react |
18 → 19 |
JSX Transform, ref as prop |
| vite |
5 → 6 |
ESM only, Node 18+ |
| eslint |
8 → 9 |
Flat config required |
| tailwindcss |
3 → 4 |
CSS-based config |
| typescript |
5.4 → 5.5+ |
Stricter inference |
Phase 5: Apply Upgrades
Upgrade Order
- Peer dependencies (TypeScript, @types/*)
- Framework packages (React, Vue core)
- Build tools (Vite, webpack)
- UI libraries (after framework)
- Utilities (lodash, date-fns)
- Dev dependencies (testing, linting)
Commands
| Manager |
Command |
| npm |
npm install <package>@latest --save |
| yarn |
yarn add <package>@latest |
| pnpm |
pnpm add <package>@latest |
Peer Dependency Conflicts
| Situation |
Solution |
| ERESOLVE error |
npm install --legacy-peer-deps |
| Still fails |
npm install --force (last resort) |
MCP Tools for Migration Search
Priority Order (Fallback Strategy)
| Priority |
Tool |
When to Use |
| 1 |
mcp__context7__query-docs |
First choice for library docs |
| 2 |
mcp__Ref__ref_search_documentation |
Official docs and GitHub |
| 3 |
WebSearch |
Latest info, community solutions |
Context7 Usage
| Step |
Tool |
Parameters |
| 1. Find library |
mcp__context7__resolve-library-id |
libraryName: "react", query: "migration guide" |
| 2. Query docs |
mcp__context7__query-docs |
libraryId: "/facebook/react", query: "react 18 to 19 migration" |
MCP Ref Usage
| Action |
Tool |
Query Example |
| Search |
mcp__Ref__ref_search_documentation |
"react 19 migration guide breaking changes" |
| Read |
mcp__Ref__ref_read_url |
URL from search results |
WebSearch Fallback
Use when Context7/Ref return no results:
"<package> <version> breaking changes migration 2025"
"<package> <error message> fix stackoverflow"
Phase 6: Apply Migrations
Process
- Use MCP tools (see section above) to find migration guide
- Apply automated code transforms via Edit tool
- Log manual migration steps for user
Do NOT apply hardcoded migrations. Always fetch current guides via MCP tools.
Phase 7: Verify Build
Commands
| Check |
Command |
| TypeScript |
npm run check or npx tsc --noEmit |
| Build |
npm run build |
| Tests |
npm test (if available) |
On Failure
- Identify failing package from error
- Search Context7/Ref for fix
- If unresolved: rollback package, continue with others
Phase 8: Report Results
Report Schema
| Field |
Description |
| project |
Project path |
| packageManager |
npm, yarn, or pnpm |
| duration |
Total time |
| upgrades.major[] |
Breaking changes applied |
| upgrades.minor[] |
Feature updates |
| upgrades.patch[] |
Bug fixes |
| migrations[] |
Applied migrations |
| skipped[] |
Already latest |
| buildVerification |
PASSED or FAILED |
| warnings[] |
Non-blocking issues |
Configuration
Options:
# Upgrade scope
upgradeType: major # major | minor | patch
# Breaking changes
allowBreaking: true
autoMigrate: true
queryMigrationGuides: true # Use Context7/Ref
# Security
auditLevel: high # none | low | moderate | high | critical
minimumReleaseAge: 14 # days
# Peer dependencies
legacyPeerDeps: false
force: false
# Verification
runBuild: true
runTests: false
runTypeCheck: true
# Rollback
createBackup: true
rollbackOnFailure: true
Error Handling
| Error |
Cause |
Solution |
| ERESOLVE |
Peer dep conflict |
--legacy-peer-deps |
| ENOENT |
Missing lock file |
npm install first |
| Build fail |
Breaking change |
Apply migration via Context7 |
| Type errors |
Version mismatch |
Update @types/* |
Rollback
Restore package.json and lock file from git, then run clean install to restore previous state.
References
Version: 1.1.0
Last Updated: 2026-01-10
1---2name: ln-711-npm-upgrader3description: Upgrades npm/yarn/pnpm dependencies with breaking change handling4---5
6# ln-711-npm-upgrader
7
8**Type:** L3 Worker
9**Category:** 7XX Project Bootstrap
10**Parent:** ln-710-dependency-upgrader
11
12Upgrades Node.js dependencies using npm, yarn, or pnpm with automatic breaking change detection and migration.
13
14---
15
16## Overview
17
18| Aspect | Details |
19|--------|---------|
20| **Input** | Project path, package manager type |
21| **Output** | Updated package.json, lock file, migration report |
22| **Supports** | npm, yarn (classic & berry), pnpm |
23
24---
25
26## Workflow
27
28See [diagram.html](diagram.html) for visual workflow.
29
30**Phases:** Pre-flight → Analyze → Security Audit → Check Outdated → Identify Breaking → Apply Upgrades → Apply Migrations → Verify Build → Report
31
32---
33
34## Phase 0: Pre-flight Checks
35
36| Check | Required | Action if Missing |
37|-------|----------|-------------------|
38| Lock file (package-lock.json, yarn.lock, pnpm-lock.yaml) | Yes | Warn and run `npm install` first |
39| package.json | Yes | Block upgrade |
40
41> Workers assume coordinator (ln-710) already verified git state and created backup.
42
43---
44
45## Phase 1: Analyze Dependencies
46
47Read package.json and categorize dependencies for upgrade priority.
48
49### Dependency Categories
50
51| Category | Examples | Priority |
52|----------|----------|----------|
53| framework | react, vue, angular | 2 (after peer deps) |
54| build | vite, webpack, esbuild | 3 |
55| ui | @radix-ui/*, tailwindcss | 4 |
56| state | @tanstack/react-query, zustand | 5 |
57| utils | lodash, date-fns | 6 |
58| dev | eslint, prettier, typescript | 7 |
59| peer | @types/*, typescript | 1 (first) |
60
61---
62
63## Phase 2: Security Audit
64
65### Commands
66
67| Manager | Command |
68|---------|---------|
69| npm | `npm audit --audit-level=high` |
70| yarn | `yarn audit --level high` |
71| pnpm | `pnpm audit --audit-level high` |
72
73### Actions
74
75| Severity | Action |
76|----------|--------|
77| Critical | Block upgrade, report |
78| High | Warn, continue |
79| Moderate/Low | Log only |
80
81---
82
83## Phase 3: Check Outdated
84
85### Commands
86
87| Manager | Command |
88|---------|---------|
89| npm | `npm outdated --json` |
90| yarn | `yarn outdated --json` |
91| pnpm | `pnpm outdated --json` |
92
93---
94
95## Phase 4: Identify Breaking Changes
96
97### Detection
98
991. Compare current vs latest major versions
1002. Check [breaking_changes_patterns.md](../ln-710-dependency-upgrader/references/breaking_changes_patterns.md)
1013. Query Context7/Ref for migration guides
102
103### Common Breaking Changes
104
105> See [breaking_changes_patterns.md](../ln-710-dependency-upgrader/references/breaking_changes_patterns.md) for full patterns.
106
107| Package | Breaking Version | Key Changes |
108|---------|------------------|-------------|
109| react | 18 → 19 | JSX Transform, ref as prop |
110| vite | 5 → 6 | ESM only, Node 18+ |
111| eslint | 8 → 9 | Flat config required |
112| tailwindcss | 3 → 4 | CSS-based config |
113| typescript | 5.4 → 5.5+ | Stricter inference |
114
115---
116
117## Phase 5: Apply Upgrades
118
119### Upgrade Order
120
1211. **Peer dependencies** (TypeScript, @types/*)
1222. **Framework packages** (React, Vue core)
1233. **Build tools** (Vite, webpack)
1244. **UI libraries** (after framework)
1255. **Utilities** (lodash, date-fns)
1266. **Dev dependencies** (testing, linting)
127
128### Commands
129
130| Manager | Command |
131|---------|---------|
132| npm | `npm install <package>@latest --save` |
133| yarn | `yarn add <package>@latest` |
134| pnpm | `pnpm add <package>@latest` |
135
136### Peer Dependency Conflicts
137
138| Situation | Solution |
139|-----------|----------|
140| ERESOLVE error | `npm install --legacy-peer-deps` |
141| Still fails | `npm install --force` (last resort) |
142
143---
144
145## MCP Tools for Migration Search
146
147### Priority Order (Fallback Strategy)
148
149| Priority | Tool | When to Use |
150|----------|------|-------------|
151| 1 | mcp__context7__query-docs | First choice for library docs |
152| 2 | mcp__Ref__ref_search_documentation | Official docs and GitHub |
153| 3 | WebSearch | Latest info, community solutions |
154
155### Context7 Usage
156
157| Step | Tool | Parameters |
158|------|------|------------|
159| 1. Find library | mcp__context7__resolve-library-id | libraryName: "react", query: "migration guide" |
160| 2. Query docs | mcp__context7__query-docs | libraryId: "/facebook/react", query: "react 18 to 19 migration" |
161
162### MCP Ref Usage
163
164| Action | Tool | Query Example |
165|--------|------|---------------|
166| Search | mcp__Ref__ref_search_documentation | "react 19 migration guide breaking changes" |
167| Read | mcp__Ref__ref_read_url | URL from search results |
168
169### WebSearch Fallback
170
171Use when Context7/Ref return no results:
172- `"<package> <version> breaking changes migration 2025"`
173- `"<package> <error message> fix stackoverflow"`
174
175---
176
177## Phase 6: Apply Migrations
178
179### Process
180
1811. Use MCP tools (see section above) to find migration guide
1822. Apply automated code transforms via Edit tool
1833. Log manual migration steps for user
184
185> Do NOT apply hardcoded migrations. Always fetch current guides via MCP tools.
186
187---
188
189## Phase 7: Verify Build
190
191### Commands
192
193| Check | Command |
194|-------|---------|
195| TypeScript | `npm run check` or `npx tsc --noEmit` |
196| Build | `npm run build` |
197| Tests | `npm test` (if available) |
198
199### On Failure
200
2011. Identify failing package from error
2022. Search Context7/Ref for fix
2033. If unresolved: rollback package, continue with others
204
205---
206
207## Phase 8: Report Results
208
209### Report Schema
210
211| Field | Description |
212|-------|-------------|
213| project | Project path |
214| packageManager | npm, yarn, or pnpm |
215| duration | Total time |
216| upgrades.major[] | Breaking changes applied |
217| upgrades.minor[] | Feature updates |
218| upgrades.patch[] | Bug fixes |
219| migrations[] | Applied migrations |
220| skipped[] | Already latest |
221| buildVerification | PASSED or FAILED |
222| warnings[] | Non-blocking issues |
223
224---
225
226## Configuration
227
228```yaml
229Options:
230 # Upgrade scope
231 upgradeType: major # major | minor | patch
232
233 # Breaking changes
234 allowBreaking: true
235 autoMigrate: true
236 queryMigrationGuides: true # Use Context7/Ref
237
238 # Security
239 auditLevel: high # none | low | moderate | high | critical
240 minimumReleaseAge: 14 # days
241
242 # Peer dependencies
243 legacyPeerDeps: false
244 force: false
245
246 # Verification
247 runBuild: true
248 runTests: false
249 runTypeCheck: true
250
251 # Rollback
252 createBackup: true
253 rollbackOnFailure: true
254```
255
256---
257
258## Error Handling
259
260| Error | Cause | Solution |
261|-------|-------|----------|
262| ERESOLVE | Peer dep conflict | --legacy-peer-deps |
263| ENOENT | Missing lock file | npm install first |
264| Build fail | Breaking change | Apply migration via Context7 |
265| Type errors | Version mismatch | Update @types/* |
266
267### Rollback
268
269Restore package.json and lock file from git, then run clean install to restore previous state.
270
271---
272
273## References
274
275- [breaking_changes_patterns.md](../ln-710-dependency-upgrader/references/breaking_changes_patterns.md)
276- [npm_peer_resolution.md](references/npm_peer_resolution.md)
277
278---
279
280**Version:** 1.1.0
281**Last Updated:** 2026-01-10