【问题标题】:Can't install correct Angular/CLI version无法安装正确的 Angular/CLI 版本
【发布时间】:2021-09-11 20:44:27
【问题描述】:

我正在尝试在 macos 上安装 nodejs 版本 10.x,以及 angular cli。但是每次尝试时,我都会收到有关 ng 与 node 版本不兼容的错误。

我一直关注这里的帖子 Unable to get Angular CLI version, though all the requirements are installed?

我在安装过程中没有收到任何错误,但我一直收到错误:

adminMini:client admin$ ng -v
Node.js version v10.24.1 detected.
The Angular CLI requires a minimum Node.js version of either v12.14 or v14.15.

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.

这就是我安装 Angular 的方式:

adminMini:client admin$ nvm use 10
Now using node v10.24.1 (npm v6.14.12)

adminMini:client admin$ npm uninstall -g @angular/cli
removed 235 packages in 2.001s

adminMini:client admin$ nvm use 10
Now using node v10.24.1 (npm v6.14.12)
adminMini:client admin$ npm install -g @angular/cli
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/Users/admin/.nvm/versions/node/v10.24.1/bin/ng -> /Users/admin/.nvm/versions/node/v10.24.1/lib/node_modules/@angular/cli/bin/ng

> @angular/cli@12.1.0 postinstall /Users/admin/.nvm/versions/node/v10.24.1/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js

npm WARN notsup Unsupported engine for @angular/cli@12.1.0: wanted: {"node":"^12.14.1 || >=14.0.0","npm":"^6.11.0 || ^7.5.6","yarn":">= 1.13.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: @angular/cli@12.1.0
npm WARN notsup Unsupported engine for @angular-devkit/architect@0.1201.0: wanted: {"node":"^12.14.1 || >=14.0.0","npm":"^6.11.0 || ^7.5.6","yarn":">= 1.13.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: @angular-devkit/architect@0.1201.0
npm WARN notsup Unsupported engine for @angular-devkit/core@12.1.0: wanted: {"node":"^12.14.1 || >=14.0.0","npm":"^6.11.0 || ^7.5.6","yarn":">= 1.13.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: @angular-devkit/core@12.1.0
npm WARN notsup Unsupported engine for @angular-devkit/schematics@12.1.0: wanted: {"node":"^12.14.1 || >=14.0.0","npm":"^6.11.0 || ^7.5.6","yarn":">= 1.13.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: @angular-devkit/schematics@12.1.0
npm WARN notsup Unsupported engine for @schematics/angular@12.1.0: wanted: {"node":"^12.14.1 || >=14.0.0","npm":"^6.11.0 || ^7.5.6","yarn":">= 1.13.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: @schematics/angular@12.1.0
npm WARN notsup Unsupported engine for open@8.2.1: wanted: {"node":">=12"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: open@8.2.1

+ @angular/cli@12.1.0
added 235 packages from 180 contributors in 7.702s

任何提示将不胜感激。

【问题讨论】:

  • Node.js 10.x 不受支持。就像,不仅 Angular 不支持,而且 Node.js 项目也不支持。更新到 12.x、14.x 或 16.x(在撰写本文时是受支持的版本)。

标签: node.js angular macos npm


【解决方案1】:

使用命令npm install -g @angular/cli 时,您将安装最新版本的angular,它需要12 版本的node。

因此,您需要将节点版本更新为 12 或通过向安装脚本指示版本来安装以前版本的 angular

npm -g install @angular/cli@8.3.25

【讨论】:

    【解决方案2】:

    您已经在使用nvm,尝试使用 nvm 安装 node 最新版本,如下所示:

    nvm install --lts
    

    检查最新的 nvm 版本,它应该大于12。原因是角度版本 8 依赖项在较低版本的节点上运行不佳。并且还建议保持版本更新以防安全漏洞。

    这会列出版本,选择版本v12.14 or v14.15LTS

    nvm list
    .....
    nvm use v12.14
    
    

    在此之后使用link 安装 Angular 版本 8+。

    【讨论】:

      猜你喜欢
      • 2018-04-11
      • 2017-01-25
      • 2018-06-13
      • 2021-04-20
      • 2019-11-07
      • 2017-08-22
      • 2017-03-23
      • 2019-10-24
      相关资源
      最近更新 更多