【问题标题】:@angular/compiler-cli@5.2.0 requires typescript@'>=2.4.2 <2.6.0' but 2.6.2 was found instead@angular/compiler-cli@5.2.0 需要 typescript@'>=2.4.2 <2.6.0' 但找到的是 2.6.2
【发布时间】:2018-06-24 22:24:01
【问题描述】:

对于已经创建的 Angular 项目,如何解决这个问题?我想用 2.6.2 Typescript

@angular/compiler-cli@5.2.0 requires typescript@'>=2.4.2 <2.6.0' but 2.6.2 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.
Please run the following command to install a compatible version of TypeScript.
    npm install typescript@'>=2.4.2 <2.6.0'
To disable this warning run "ng set warnings.typescriptMismatch=false".
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'*

【问题讨论】:

  • 运行npm install typescript。忽略警告。
  • 谢谢,通过运行npm install typescript 它安装了 2.4.2 版
  • 试试npm install typescript@latest --peer

标签: angular typescript npm angular-cli


【解决方案1】:

问题很明确...您的 Angular CLI 版本需要 Typescript 较低版本。

您需要降级您的 Typescript 版本。

在您的 package.json 更改中:

"typescript": "^2.6.2",

"typescript": "^2.4.2",

然后运行

npm install

【讨论】:

  • 如果 Angular CLI 有如此严格的版本要求,我会主张固定版本,而不是保持插入符号范围
  • 非常感谢您的宝贵建议 :)
猜你喜欢
  • 2019-02-20
  • 2020-05-25
  • 1970-01-01
  • 2019-12-04
  • 2018-10-31
  • 2018-02-04
  • 2020-11-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多