Skip to content

ng update Angular 20 → 21 fails with “Invalid Version:” #32517

@ppaternostro

Description

@ppaternostro

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

Angular 20 CLI updater

Description

Running ng update @angular/core@21 @angular/cli@21 on an Angular 20 project fails immediately with:

The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 21.1.4 to perform the update.
Using package manager: npm
Collecting installed dependencies...
Found 42 dependencies.
An unhandled exception occurred: Invalid Version: 
See "/tmp/ng-ikfuQW/angular-errors.log" for further details.

Even using --migrate-only or npx @angular/cli@21 triggers the same error.

Direct npm installation of Angular 21 packages works, but the updater cannot run migrations.

Minimal Reproduction

  1. Create an Angular 20 project (e.g., ng new test20 with CLI 20.x).
  2. Optionally add Angular Material or ESLint packages (version 20).
  3. Run: ng update @angular/core@21 @angular/cli@21
  4. Observe the error: An unhandled exception occurred: Invalid Version:
    See "/tmp/ng-XXXXX/angular-errors.log" for further details.

Exception or Error

TypeError: Invalid Version: 
    at new SemVer (/tmp/angular-cli-packages-tDrRUS/node_modules/semver/classes/semver.js:40:13)
    at compare (/tmp/angular-cli-packages-tDrRUS/node_modules/semver/functions/compare.js:5:3)
    at Object.gte (/tmp/angular-cli-packages-tDrRUS/node_modules/semver/functions/gte.js:4:30)
    at shouldForcePackageManager (/tmp/angular-cli-packages-tDrRUS/node_modules/@angular/cli/src/commands/update/utilities/cli-version.js:187:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async UpdateCommandModule.run (/tmp/angular-cli-packages-tDrRUS/node_modules/@angular/cli/src/commands/update/cli.js:210:34)
    at async UpdateCommandModule.handler (/tmp/angular-cli-packages-tDrRUS/node_modules/@angular/cli/src/command-builder/command-module.js:160:28)

Your Environment

- Angular CLI: 20.3.16
- Angular Core: 20.3.16
- Node: 20.20.0  
- NPM: 10.8.2  
- OS: Ubuntu 24.04.4 LTS

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions