尽管安装了所有要求,但无法获得 Angular CLI 版本?

Tan*_*ner 13 macos node.js npm angular-cli angular

我在使用 Angular CLI 做任何事情时都遇到了困难。我有节点,NPM。和 Angular 都安装了,当我which在终端中运行命令时,它们都存在于我的/user/local/bin

这是我的当前版本node.js:v11.8.0

这是我的当前版本npm:6.5.0

当我运行时,ng -v我无法获取版本并收到以下消息:

$ ng -v
Node.js version v11.8.0 detected.
The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.
Run Code Online (Sandbox Code Playgroud)

我曾尝试卸载 Angular CLI,但得到了相同的结果。

Kun*_*vič 18

I would recommend you to remove your NodeJS installation completely and re-install NodeJS through NVM. This way you can easily switch between multiple NodeJS versions and the other benefit of that for each active NodeJS version you may able to install specific Angular CLI version.

e.g:

nvm install 11  
nvm install 12
nvm alias default 12  
nvm use 11  
npm install @angular/cli -g
Run Code Online (Sandbox Code Playgroud)

Also see some details on Angular CLI version here

P.S
If you where using brew, to uninstall NodeJS follow this steps:

brew uninstall node; 
# or `brew uninstall --force node` which removes all versions
brew cleanup;
rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm /usr/local/bin/node;
Run Code Online (Sandbox Code Playgroud)


Ren*_*abu 9

Angular CLI 需要当前有效的 LTS 或维护 LTS 版本的 Node ( https://angular.io/guide/setup-local#nodejs )。哪个版本 11 不是。

Node.JS 团队不再支持 Node.JS 11,因为六个月后,奇数版本(9、11 等)将不再受支持。更多信息: https: //nodejs.org/en/about/releases

解决方案:将Node版本升级到12+


小智 7

因为,Angular CLI 要求 Node.js 的最低版本为 v10.13 或 v12.0。

第 1 步:安装 v12.x

nvm install 12
Run Code Online (Sandbox Code Playgroud)

第 2 步:使用 v12.x

nvm use 12
Run Code Online (Sandbox Code Playgroud)

第 3 步:安装 Angular CLI

npm install @angular/cli -g
Run Code Online (Sandbox Code Playgroud)

第 4 步:检查版本,验证其已安装

ng --version
Run Code Online (Sandbox Code Playgroud)

输出示例图像: https://i.stack.imgur.com/9jr15.png


小智 7

对于 Node v8 安装 Angular cli 7.3 版本

npm i @angular/cli@7.3.10
Run Code Online (Sandbox Code Playgroud)