发生未处理的异常:找不到临时包的 bin:@angular/cli

An unhandled exception occurred: Cannot locate bin for temporary package: @angular/cli

我正在尝试按照本指南将项目的 Angular 版本从 8 更新到 11:https://update.angular.io/?l=3&v=8.0-11.0。到目前为止,更新到 v9 一直有效,但是当 运行 ng update @angular/core@10 @angular/cli@10 我现在收到一条错误消息,我找不到 post 在线解决它。

The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
✔ Package successfully installed.
An unhandled exception occurred: Cannot locate bin for temporary package: @angular/cli.
See "/private/var/folders/qy/0lhcj3516gb2hmdfcfj8jpf40000gn/T/ng-G8l2Tv/angular-errors.log" for further details.

日志显示如下

[error] Error: Cannot locate bin for temporary package: @angular/cli.
    at Object.runTempPackageBin (/usr/local/lib/node_modules/@angular/cli/utilities/install-package.js:116:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async UpdateCommand.validateAndRun (/usr/local/lib/node_modules/@angular/cli/models/command.js:136:22)
    at async Object.runCommand (/usr/local/lib/node_modules/@angular/cli/models/command-runner.js:205:24)
    at async default_1 (/usr/local/lib/node_modules/@angular/cli/lib/cli/index.js:70:31)

我试过“npm ci”来重新安装所有节点模块,但我认为这没有帮助。有什么解决方法的建议吗?

这样做:

  1. sudo npm uninstall -g @angular/cli
  2. sudo npm i -g @angular/cli@YOUR_LOCAL_VERSION(取自package.json到你的项目中)

如果没有帮助 - 添加 package.json 文件数据 & ng --version

正在从 12.0.0 升级到 12.0.1 并收到相同的错误 - upgrading/installing 全局 @angular/cli 修复了它