angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Running the optional angular build migration installs incompatible version of @angular/build

Open simhnna opened this issue 6 months ago • 4 comments

Command

update

Is this a regression?

  • [ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Running the optional migration after skipping the build migration during initial update incorrectly installs @angular/build v20 which is not compatible

Minimal Reproduction

https://github.com/simhnna/angular-build-migration-demo/tree/8971afceeaf60bbe9fff4c9a2777b7711dcb095f

Run ng update @angular/cli --name=use-application-builder

The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 20.1.0 to perform the update.
Using package manager: npm
Collecting installed dependencies...
Found 22 dependencies.
** Executing 'use-application-builder' of package '@angular/cli' **

❯ Migrate application projects to the new build system.
  Application projects that are using the '@angular-devkit/build-angular' package's 'browser' and/or 'browser-esbuild' builders will be migrated to use the new 'application' builder.
  You can read more about this, including known issues and limitations, here: https://angular.dev/tools/cli/build-system-migration
    The output location of the browser build has been updated from "dist/project" to "dist/project/browser". You might need to adjust your deployment pipeline or, as an alternative, set outputPath.browser to "" in order to maintain the previous functionality.
UPDATE package.json (1032 bytes)
UPDATE angular.json (2749 bytes)
✔ Packages installed successfully.
  Migration completed (2 files modified).

It installs @angular/build@20 because it uses @angular/cli@20 to run the update

Exception or Error


Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 18.2.20
Node: 22.17.0
Package Manager: npm 10.9.2
OS: linux x64

Angular: 18.2.13
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.20
@angular-devkit/build-angular   18.2.20
@angular-devkit/core            18.2.20
@angular-devkit/schematics      18.2.20
@angular/cli                    18.2.20
@schematics/angular             18.2.20
rxjs                            7.8.2
typescript                      5.4.5
zone.js                         0.14.10

Anything else relevant?

No response

simhnna avatar Jul 10 '25 10:07 simhnna

I found something that works. I'm not sure through if my change is correct for all other uses of ng update. https://github.com/simhnna/angular-cli/commit/f66ff3b0ad90adb7c4103e7cb4f8998575f52975

With the change migrateOnly gets passed the package name without a specifier and running ng update @angular/cli@18 --name=use-application-builder does the correct thing. If that's an actual fix I can open a pull request

simhnna avatar Jul 10 '25 13:07 simhnna

I found something that works. I'm not sure through if my change is correct for all other uses of ng update. simhnna@f66ff3b

With the change migrateOnly gets passed the package name without a specifier and running ng update @angular/cli@18 --name=use-application-builder does the correct thing. If that's an actual fix I can open a pull request

Hi @simhnna Even I am facing the same issue. We have install angular 19.2.15 recently but didn't do build migration when cli prompted during ng update as we wanted to do this migration separately. However when I am trying to do it now, using ng update @angular/cli@19 --name=use-application-builder it starts installing temporary Angular CLI version 20.2.0 and installs @angular/build@20.

How did you resolve it using ng update @angular/cli@18 --name=use-application-builder? When I run it it errors out with 'Package not installed' because I am already on angular cli 19.

ng update @angular/cli@18 --name=use-application-builder The installed Angular CLI version is outdated. Installing a temporary Angular CLI versioned 18.2.20 to perform the update. Package specifier has no effect when using "migrate-only" option. Using package manager: npm Collecting installed dependencies... Found 62 dependencies. Package is not installed.

sj014342 avatar Aug 22 '25 07:08 sj014342

I applied my patch to my locally installed angular CLI before running the migrate command

simhnna avatar Aug 22 '25 19:08 simhnna

I'm on the same boat. Any updates on this?

ThunderCls avatar Dec 02 '25 18:12 ThunderCls