ng update stops on peer dependency errors when moving to a much newer Angular
Incompatible peer dependencies found.Short answer
Angular supports updates one major version at a time, so a jump such as 8 to 13 in one go leaves packages whose peer ranges do not match. Update each major in turn with ng update, update third-party packages that block a step, and use --force only for a conflict you have judged harmless.
Fix it fast
1Find out which cause you have
Print the Angular packages currently installed. Every @angular/* package must be on the same major before you start the next step.
npm ls @angular/core @angular/cli @angular/material2Match what you see, then jump to its fix
- 1
The conflict names packages that need a range several majors away from the one you targetYou skipped majorsFix - 2
Incompatible peer dependencies found, naming a package that is not @angular/core or @angular/cliA third-party package has an older peer rangeFix - 3
Error: Repository is not clean. Please commit or stash any changes before updatingng update refuses because the repository has uncommitted changesFix
- 1
What does the error look like?
Incompatible peer dependencies found.Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.Error: Repository is not clean. Please commit or stash any changes before updating
Cause 1 of 3
You skipped majors
1Check
Compare the major in package.json with the one you are trying to install. The Angular release policy tells you to cross several majors one at a time.
npm ls @angular/core --depth=02Fix
Commit your work, then update core and CLI to the next major only, finish that step (build and tests), and repeat. The version you pass is the next major, not the final one.
git status
npx ng update @angular/core@<next-major> @angular/cli@<next-major>3Verify
After each step, the build passes and npm ls shows one major for every @angular package.
npm ls @angular/core --depth=0
npx ng buildConfirmed by angular.dev
Cause 2 of 3
A third-party package has an older peer range
1Check
Libraries declare which Angular versions they accept in peerDependencies. A release built for the old major rejects the new core.
npm ls <package-name>2Fix
Update that package in the same ng update call, so its own migration runs, or move to a release that lists your target major. Only then add --force, which ignores peer version mismatches and does not fix an API that really changed.
npx ng update @angular/core@<next-major> @angular/cli@<next-major> <package-name>
# last resort, one package, after reading its changelog:
npx ng update <package-name> --force3Verify
The update completes and the build shows no template or type errors from that library.
npx ng buildConfirmed by github.com
Cause 3 of 3
ng update refuses because the repository has uncommitted changes
1Check
Untracked files count too, not only edits; node_modules and build output should be in .gitignore.
git status --short2Fix
Commit or stash first. Pass --create-commits so each update and migration becomes its own commit; use --allow-dirty only when you accept losing that clean diff.
git add -A && git commit -m "before angular update"
npx ng update @angular/core@<next-major> @angular/cli@<next-major> --create-commits3Verify
git log shows one commit per migration, ready to review or revert.
git log --oneline -n 10Confirmed by angular.dev
How do I stop it coming back?
- Update every Angular major as it ships, or at least within a supported window, instead of letting years pile up.
- Run ng update from a clean branch and keep --create-commits on, so a bad step can be reverted alone.
- Check the Node.js and TypeScript ranges on the Angular versions page before each step.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npm install refuses with ERESOLVE and a peer dependency conflict
npm error ERESOLVE unable to resolve dependency tree
ERESOLVE means two packages in your tree ask for incompatible versions of a shared peer dependency, and npm 7 or newer refuses to guess.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix