angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.72k stars 11.98k forks source link

`ng update` fails with Yarn #27731

Open LaXiS96 opened 3 months ago

LaXiS96 commented 3 months ago

Command

update

Is this a regression?

The previous version in which this bug was not present was

<14 probably, not sure as it was a long time ago

Description

While updating a v15 application using Yarn (non-PnP), the ng update command fails with an unhelpful error. The error claims there is no packageManager field in package.json, which is not true. Even if the field is really missing, ng update adds it but the next run will throw the same error.

The only workaround I found is to use npm to do the update (set packageManager: "npm@10.7.0" in package.json, remove cli.packageManager from angular.json), and then revert to Yarn after the update.

It does not look like a Yarn issue, the behavior is the same with 3.4.1 or 4.2.2.

Minimal Reproduction

  1. corepack enable
  2. npx --package=@angular/cli@15 ng new ng15 --package-manager=yarn
  3. add .yarnrc.yml with content: nodeLinker: node-modules
  4. yarn install
  5. ng update @angular/core@16 @angular/cli@16 --verbose --allow-dirty

Exception or Error

PS > ng update @angular/core@16 --verbose
Locating potential npmrc files:
Locating potential yarnrc files:
Trying 'C:\Users\me\.yarnrc'...found.
Trying 'C:\Users\me\.yarnrc'...found.
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 16.2.14 to perform the update.
! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing yarn@3.4.1+sha512.a333bf9c2557d71f5ba87dd1446cde24bb9c35301ec29dd2baba577b3f9d1ab61348b66a1324de9088c40a996c5b9203794da8bf14cab9fae6a6eccc00cb8078.
! For more details about this field, consult the documentation at https://nodejs.org/api/packages.html#packagemanager

✖ Packages installation failed, see above.

Your Environment

Angular CLI: 15.2.11
Node: 18.20.3
Package Manager: yarn 3.4.1
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1502.11
@angular-devkit/build-angular   15.2.11
@angular-devkit/core            15.2.11
@angular-devkit/schematics      15.2.11
@angular/cli                    15.2.11
@schematics/angular             15.2.11
rxjs                            7.8.1
typescript                      4.9.5

Anything else relevant?

No response

zstundys commented 2 months ago

I get a similar issue too - using WSL image