angulartypescriptnpm

Unable to install angular-devkit/build-angular


I'm getting an error when I run npm install --save-dev @angular-devkit/build-angular. I'm not sure which version of build-angular I need.

My dependencies:

"dependencies": {
  "@angular/common": "^20.2.0",
  "@angular/compiler": "^20.2.0",
  "@angular/core": "^20.2.0",
  "@angular/forms": "^20.2.0",
  "@angular/platform-browser": "^20.2.0",
  "@angular/router": "^20.2.0",
  "rxjs": "~7.8.0",
  "tslib": "^2.3.0",
  "zone.js": "~0.15.0"
},
"devDependencies": {
  "@angular/build": "^20.2.1",
  "@angular/cli": "^20.2.1",
  "@angular/compiler-cli": "^20.2.0",
  "@types/jasmine": "~5.1.0",
  "jasmine-core": "~5.9.0",
  "karma": "~6.4.0",
  "karma-chrome-launcher": "~3.2.0",
  "karma-coverage": "~2.2.0",
  "karma-jasmine": "~5.1.0",
  "karma-jasmine-html-reporter": "~2.1.0",
  "typescript": "~5.9.2"
}

Error:

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: ng-webapp@0.0.0
npm error Found: @angular/compiler@20.2.2
npm error node_modules/@angular/compiler
npm error   peer @angular/compiler@"^20.0.0" from @angular/build@20.2.1
npm error   node_modules/@angular/build
npm error     dev @angular/build@"^20.2.1" from the root project
npm error   peer @angular/compiler@"20.2.2" from @angular/compiler-cli@20.2.2
npm error   node_modules/@angular/compiler-cli
npm error     peer @angular/compiler-cli@"^20.0.0" from @angular/build@20.2.1
npm error     node_modules/@angular/build
npm error       dev @angular/build@"^20.2.1" from the root project
npm error     dev @angular/compiler-cli@"^20.2.0" from the root project
npm error   2 more (@angular/core, the root project)
npm error
npm error Could not resolve dependency:
npm error dev @angular-devkit/build-angular@"20.2.0" from the root project
npm error
npm error Conflicting peer dependency: @angular/compiler@20.2.3
npm error node_modules/@angular/compiler
npm error   peer @angular/compiler@"20.2.3" from @angular/compiler-cli@20.2.3
npm error   node_modules/@angular/compiler-cli
npm error     dev @angular/compiler-cli@"^20.2.0" from the root project
npm error     peer @angular/compiler-cli@"^20.0.0" from @angular-devkit/build-angular@20.2.0
npm error     node_modules/@angular-devkit/build-angular
npm error       dev @angular-devkit/build-angular@"20.2.0" from the root project
npm error     2 more (@angular/localize, ng-packagr)

What I get from npm info:

{
  jest: '^29.5.0',
  karma: '^6.3.0',
  'ng-packagr': '^20.0.0',
  protractor: '^7.0.0',
  typescript: '>=5.8 <6.0',
  tailwindcss: '^2.0.0 || ^3.0.0 || ^4.0.0',
  '@angular/ssr': '^20.2.1',
  'browser-sync': '^3.0.2',
  '@angular/core': '^20.0.0',
  '@web/test-runner': '^0.20.0',
  '@angular/localize': '^20.0.0',
  '@angular/compiler-cli': '^20.0.0',
  'jest-environment-jsdom': '^29.5.0',
  '@angular/service-worker': '^20.0.0',
  '@angular/platform-server': '^20.0.0',
  '@angular/platform-browser': '^20.0.0'
}

Solution

  • You already have "@angular/build": "^20.2.1". That's the package for the new build system. Instead, align all "@angular/*" packages to the same patch and use the new builders.

    1. First uninstall @angular-devkit/build-angular (if you installed any version of it):
    npm rm @angular-devkit/build-angular
    
    1. Then:
    npm i --save-dev @angular/cli@20.2.3 @angular/build@20.2.3 @angular/compiler-cli@20.2.3 typescript@~5.9.2
    npm i @angular/core@20.2.3 @angular/common@20.2.3 @angular/compiler@20.2.3 @angular/forms@20.2.3 @angular/platform-browser@20.2.3 @angular/router@20.2.3
    
    1. Just to be completely sure:
    rm -rf node_modules package-lock.json && npm i
    
    1. Then, in your angular.json fine your build configs and use "builder": "@angular/build:application".