angular / angular/angular-cli

v21.2.2 seems to be unable to handle npm workspaces

未關閉
#32,787 6 則留言 23 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular/cli freq1: low gemini-triaged ng update DX severity5: regression type: bug/fix
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

### Command

update

### Is this a regression?

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

### The previous version in which this bug was not present was

v20

### Description

While using npm workspaces, `ng update @angular/core@21` (or any other angular package) with installed version `@angular/cli@21` fails with the following error:
```
Using package manager: npm
Collecting installed dependencies...
Found 1 dependencies.
Package '@angular/core' is not a dependency.
```
This does not happen in the same repo with v20 installed (and trying to update to v20). It also does not happen in a repo without npm workspaces.

### Minimal Reproduction

See https://github.com/jsangmeister/angular-cli-repro

I created the repo as follows:
```
npm init
mkdir apps
cd apps
ng new test-app
```
and then moving some files to the top level, e.g., the git folder.

When running `cd apps/test-app && ng update @angular/core@21`, the error appears.

### Exception or Error

```text
Package '@angular/core' is not a dependency.
```

### Your Environment

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

Angular CLI : 21.2.2
Angular : 21.2.4
Node.js : 24.10.0
Package Manager : npm 11.9.0
Operating System : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.2.2 │ ^21.2.2 │
│ @angular/cli │ 21.2.2 │ ^21.2.2 │
│ @angular/common │ 21.2.4 │ ^21.2.0 │
│ @angular/compiler │ 21.2.4 │ ^21.2.0 │
│ @angular/compiler-cli │ 21.2.4 │ ^21.2.0 │
│ @angular/core │ 21.2.4 │ ^21.2.0 │
│ @angular/forms │ 21.2.4 │ ^21.2.0 │
│ @angular/platform-browser │ 21.2.4 │ ^21.2.0 │
│ @angular/router │ 21.2.4 │ ^21.2.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
│ vitest │ 4.1.0 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
```

### Anything else relevant?

_No response_

貢獻指南

開啟貢獻指南

研究方向

從連結的最小重現開始,在 npm-workspaces 儲存庫中使用 Angular CLI 21.2.2 執行 `cd apps/test-app 6ff ng update @angular/core@21`。將結果與在 v20 下進行相同更新或不使用 workspaces 時的結果比較;當 Angular 套件被辨識為相依性,且更新在沒有所報錯誤的情況下繼續進行時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, node.js, typescript
領域
cli, tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。