无法从 Mac 卸载或更新 Angular CLI

cd4*_*415 5 angular

我当前安装了以下版本

Angular CLI: 9.1.9
Node: 17.4.0
OS: darwin x64

Angular: 
... 
Ivy Workspace: 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.901.9
@angular-devkit/core         9.1.9
@angular-devkit/schematics   9.1.9
@schematics/angular          9.1.9
@schematics/update           0.901.9
rxjs                         6.5.4
Run Code Online (Sandbox Code Playgroud)

由于我无法更新 angular-cli (ng update),我尝试使用卸载它

sudo npm uninstall -g angular-cli
sudo npm uninstall -g @angular/cli
sudo npm cache clean --force
sudo npm cache verify --force
Run Code Online (Sandbox Code Playgroud)

这些命令没有报告任何问题并且似乎执行得很好。但是,如果我发出ng version在发出这些命令后发出,我仍然会得到如上所示的旧版本。

Google 上的 Stackoverflow 上的答案都没有帮助,我大概读了 50 个。

尝试更新也失败

sudo ng update

The "@angular-devkit/schematics" package cannot be resolved from the workspace root directory. This may be due to an unsupported node modules structure.
Please remove both the "node_modules" directory and the package lock file; and then reinstall.
If this does not correct the problem, please temporarily install the "@angular-devkit/schematics" package within the workspace. It can be removed once the update is complete.
Run Code Online (Sandbox Code Playgroud)

我不在任何项目文件夹内,所以我不明白为什么它抱怨 node_modules 目录或包锁定文件。

我在 Mac BigSur 上。

cd4*_*415 1

无论我做什么,我发现的帖子都不起作用。而且 Angular github 在大多数情况下都是无用的。

最终,我不得不卸载或更新 Angular CLI,因为我发现所有解决方案都不起作用。相反,我决定从 Mac 上卸载 Node 并重新安装。

要完全卸载节点,我遵循了这篇文章 https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/

一旦我卸载了节点,ng version就不再报告任何角度,所以一切都很好。然后我下载了最新的节点并将其安装在我的 Mac 上。之后我只是发出命令来安装 Angular,如下所示:

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

此后,我的 Angular 版本为 13.x