Angular 12:我不能做 ng serve --open

Angluar 12: I can't do ng serve --open

我不知道这是否是一个错误,但每次我在我的终端中 ng serve --open 我总是收到这条消息:

D:rdYR\AppDev\bigProject\public>ng serve --open
This version of CLI is only compatible with Angular versions ^13.0.0,
but Angular version 12.2.5 was found instead.

Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/

我只用angular12

到目前为止我尝试了什么

ng --version
npm uninstall -g @angular/cli
npm cache clean --force

npm install -g @angular/cli@12.1.0
ng --version

就像下面的答案一样,我试着做 npm cache clean --force 但我从我的终端得到这个:

npm WARN using --force Recommended protections disabled.

我也尝试去 %appdata% 并删除 npm-cache 文件夹和 运行 npm cache clean --force 再次,但我仍然得到这个:

npm WARN using --force Recommended protections disabled.

当我尝试 ng-serve 时,我仍然收到消息(以上)

这样做。

ng --version
npm uninstall -g @angular/cli
npm cache clean --force

npm install -g @angular/cli@12.1.0
ng --version

您也可以尝试使用上述命令安装其他版本,例如 12.2 或最新的 12.*。作为参考,我提到了 12.1.0


如果您遇到禁用错误,请执行以下操作:

手动删除:输入windows search - 运行 - %appdata% - delete npm-cache folder 重新安装应该修复所有问题的节点

npm install -g npm@latest

运行 以上命令仅在删除 npm-cache 文件夹后