angular / angular/angular-cli

New Angular projects install jasmine-core ~5.7.0 but use 4.6.1

オープン
#30,575 コメント 7 件 リアクション 3 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
27k
フォーク
11.8k
平均マージ
14時間 23分
マージ済み PR(30日)
162

説明

### Which @angular/* package(s) are the source of the bug?

Don't known / other

### Is this a regression?

Yes

### Description

The package.json file generated by `ng new` includes the dev dependency `"jasmine-core": "~5.7.0"`, but jasmine-core 4.6.1 is also installed and used to run tests in Karma.
Steps to reproduce:

1. Install @angular/cli 20.0.3.
2. Run `ng new some-name` and accept all the defaults.
3. Note the jasmine-core dependency in package.json.
4. Run `npm test` and note the Jasmine version displayed in the browser.
5. Run `npm ls jasmine-core`.

Expected: The versions from steps 3 and 4 agree, and step 5 shows that only a single version of jasmine-core is installed.
Observed: Step 3 and 4 show different major versions, and step 5 shows that two different versions of jasmine-core are installed.

The problem is that karma-jasmine declares a dependency on jasmine-core 4.x. `ng new` tries to set up the project to use jasmine-core 5.x, but it doesn't add [the necessary override](https://jasmine.github.io/pages/faq.html#001-karma).

Note: I'm not an Angular user, but I do maintain Jasmine. I've seen this version mismatch cause a couple of problems. One is that Angular users are occasionally confused about which major version of jasmine-core they're actually using. The other is that it makes jasmine-core download statistics pretty much useless for determining uptake of the latest major version, since an unknown but probably large portion of 5.x downloads are from Angular users who are actually still running 4.x.

### Please provide a link to a minimal reproduction of the bug

_No response_

### Please provide the exception or error you saw

```true

```

### Please provide the environment you discovered this bug in (run `ng version`)

```true
Angular CLI: 20.0.3
Node: 20.19.0
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: 20.0.4
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package Version
------------------------------------------------------
@angular-devkit/architect 0.2000.3
@angular-devkit/core 20.0.3
@angular-devkit/schematics 20.0.3
@angular/build 20.0.3
@angular/cli 20.0.3
@schematics/angular 20.0.3
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
```

### Anything else?

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

`ng new` を実行して生成された package.json を調べ、Angular CLI 20.0.3 で問題を再現してから、`npm test` と `npm ls jasmine-core` を実行します。Jasmine と Karma の依存関係を定義している Angular CLI のプロジェクト生成ソースを追跡します。宣言されたバージョンとランタイムのバージョンが一致し、npm が jasmine-core を1つのバージョンだけインストールすれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
cli, testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
64/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。