尽管安装了所有要求,但无法获得 Angular CLI 版本? [英] Unable to get Angular CLI version, though all the requirements are installed?
问题描述
我在使用 Angular CLI 做任何事情时遇到困难.我有节点,NPM.和 Angular 全部安装,当我在终端中运行 which
命令时,它们都存在于我的 /user/local/bin
I am having difficulties doing anything with the Angular CLI. I have Node, NPM. and Angular all installed, when I run the which
command in the terminal they all exist in my /user/local/bin
这是我当前的node.js
:v11.8.0
This is my current node.js
: v11.8.0
这是我当前的npm
:6.5.0
This is my current npm
: 6.5.0
当我运行 ng -v
时,我无法获取版本并收到以下消息:
When I run ng -v
I am unable to get the version and I get the following message:
$ 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.
我曾尝试卸载 Angular CLI,但得到了相同的结果.
I have tried uninstalling the Angular CLI but, getting the same results.
推荐答案
我建议您完全删除 NodeJS 安装并通过 NVM 重新安装 NodeJS.通过这种方式,您可以轻松地在多个 NodeJS 版本之间切换,并且对于每个活动的 NodeJS 版本,您可以安装特定的 Angular CLI 版本.
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.
例如:
nvm install 11
nvm install 12
nvm alias default 12
nvm use 11
npm install @angular/cli -g
- Mac/Linux:https://github.com/nvm-sh/nvm
- Windows:https://github.com/coreybutler/nvm-windows
还可以在此处
附注
如果您使用 brew,请按照以下步骤卸载 NodeJS:
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;
这篇关于尽管安装了所有要求,但无法获得 Angular CLI 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!