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

未关闭
#30,575 7 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
angular, typescript
领域
cli, testing

调研方向

通过运行 ng new 并检查生成的 package.json,使用 Angular CLI 20.0.3 重现该问题,然后运行 npm testnpm ls jasmine-core。追踪 Angular CLI 中定义 Jasmine 和 Karma 依赖的项目生成源代码;当声明的版本与运行时版本一致,并且 npm 只安装一个 jasmine-core 版本时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

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

Please provide the environment you discovered this bug in (run ng version)
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

主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
16 小时 35 分钟
30 天内合并 PR
176

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。