How Codex Helped Me Finish an Angular 20 to 21 Upgrade in a Monorepo
Angular migration is a PITA. Moving from 20.3.16 to 21.1.4 in a monorepo was rough.
If I could share this fix with my past self (pre-AI), I would’ve slapped myself for wasting so much time.
I treated the Angular migration docs like the holy Bible and still got kicked in the balls by this:
Error: Cannot find module '@angular/compiler-cli'
Require stack:
.../node_modules/@angular/core/schematics/...
I usually jump between Stack Overflow (RIP), GitHub issues, and random docs, but that’s a lot of wasted time.
This time, instead of another CTRL+C / CTRL+V loop through search results, I pasted the exact command and error into Codex.
Codex pointed out the real issue: module resolution context in a monorepo.
I was running the command from one package, but schematics were resolving from a different node_modules location.
The fix
Run the migration with explicit resolution and an explicit CLI path:
cd <app-package-dir>
NODE_PATH=./node_modules \
node ../node_modules/@angular/cli/bin/ng.js \
update @angular/core --migrate-only --from 20.3.16 --to 21.1.4 --force
Then rerun the migration command.
Boom. Done. It worked.
In the past, I had manually bumped versions in package.json, so I assumed I was done.
I was not done.
The migration steps had not actually run. Once the resolution issue was fixed and --migrate-only ran properly, the missing migration changes finally applied.
Anyway, to digress, it’d be really nice in this day and age for edge cases to be tested in a variety of simulated workspaces. Make it as jank as possible and see what breaks. Then provide recovery steps in the documentation.