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

`ng update` fails when using yarn and `npmMinimalAgeGate`

Open Cynaeon opened this issue 2 months ago • 1 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

Yarn recently introduced npmMinimalAgeGate which prevents downloading npm packages that are newer than the specified age. If using it and trying to install packages using ng update it just fails without any clear reason. What I would expect to happen is that ng update would list and download available packages while respecting the npmMinimalAgeGate, or at the very least the error could be made more descriptive.

Minimal Reproduction

Set package manager as yarn v4.10.0 or newer. Set npmMinimalAgeGate so that it is more than the age of the latest Angular version, for example I have npmMinimalAgeGate: 10080 which is one week, and at the moment the newest Angular is 20.3.4 which is about 5 days old. Then try to run any update command like ng update @angular/core.

Exception or Error

$ ng update @angular/core
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 20.3.5 to perform the update.
Using package manager: yarn
Collecting installed dependencies...
Found 120 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/compiler-cli @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/animations @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/common @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/compiler @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/core @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/forms @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/platform-browser @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "20.3.4" (was "19.2.15")...
    Updating package.json with dependency @angular/router @ "20.3.4" (was "19.2.15")...
UPDATE package.json (13525 bytes)
√ Cleaning node modules directory
× Unable to install packages

Your Environment

$ ng version

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


Angular CLI: 19.2.17
Node: 22.20.0
Package Manager: yarn 4.10.3
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.17
@angular-devkit/build-angular   19.2.17
@angular-devkit/core            19.2.17
@angular-devkit/schematics      19.2.17
@angular/cdk                    19.2.19
@angular/cli                    19.2.17
@angular/material               19.2.19
@schematics/angular             19.2.17
ng-packagr                      19.2.2
rxjs                            7.8.2
typescript                      5.8.3

Anything else relevant?

No response

Cynaeon avatar Oct 13 '25 06:10 Cynaeon

I wonder if this is (realistically & maintainably) fixable without delegating the version upgrade to the package manager in the middle of the current upgrade logic..?

As a workaround, I think it's possible to run with a specific version. E.g. when encountering this error, you can run the following command instead (note the patch version is one before the release):

ng update @angular/[email protected] @angular/[email protected] # [... the other packages]

hybrist avatar Oct 13 '25 15:10 hybrist