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

`ng update` doesn't work with Yarn PnP

Open michaelfaith opened this issue 7 months ago • 0 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

When running ng update <library> in a project that uses Yarn PnP, the command fails with the following error

Package '@angular/material' is not a dependency.

This was reported in the PnP support status thread and a work around listed here https://github.com/angular/angular-cli/issues/16980#issuecomment-1331725784

The workaround requires temporarily disabling PnP, running the update, and then re-enabling PnP, which is not a great experience.

Minimal Reproduction

Run ng update @angular/core in a project that's set up with Yarn pnp.

Exception or Error

ng update @angular/core @angular/cli @angular/material                                                             
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 17.0.3 to perform the update.
√ Packages successfully installed.
Using package manager: yarn
Collecting installed dependencies...
Found 0 dependencies.
Package '@angular/core' is not a dependency.

Your Environment

`ng version` also doesn't work in PnP

Running update with 17.0.3 on a project that has 16.2.1 installed.
Node 18.13.0
Yarn 4.0.2
Win x64

Anything else relevant?

I believe the code responsible for this issue is this utils function that gathers all dependencies from the project's package.

https://github.com/angular/angular-cli/blob/main/packages/angular/cli/src/utilities/package-tree.ts#L53-L86

michaelfaith avatar Nov 27 '23 21:11 michaelfaith