错误
存储库不干净。请在更新前提交或存储任何更改
当我从版本 7 更新到 Angular 8 时。
Angular 升级指南 https://update.angular.io/#7.0:8.0
D:\app-test> ng update @angular/cli @angular/core
npm cache verify
存储库不干净。请在更新前提交或存储任何更改。
更新版本
PS D:\app-test> ng update
Using package manager: 'npm'
Collecting installed dependencies...
Found 58 dependencies.
We analyzed your package.json, there are some packages to update:
Name Version Command to update
--------------------------------------------------------------------------------
@angular/cdk 7.2.2 -> 8.0.1 ng update @angular/cdk
@angular/core 7.2.15 -> 8.0.1 ng update @angular/core
@angular/core 7.2.2 -> 7.2.15 ng update @angular/core
@angular/material 7.3.7 -> 8.0.1 ng update @angular/material
rxjs 6.3.3 -> 6.5.2 ng update rxjs
There might be additional packages that are outdated.
Run "ng update --all" to try to update all at the same time.
PS D:\app-test> ng update @angular/cdk
Repository is not clean. Please commit or stash any changes before updating.
我检查了项目中没有安装 git。
有效的解决方案
git commit
谷歌搜索后我有这发生在Angular 8之后。
漏洞
https://github.com/angular/angular-cli/issues/14600
原文由 afeef 发布,翻译遵循 CC BY-SA 4.0 许可协议
以下内容对我将 Angular 13 项目升级到 Angular 14(2022 年 10 月)有用:
在您的项目目录中,使用管理员权限打开命令提示符。然后运行以下命令:
ng update @angular/core@14 @angular/cli@14 --allow-dirty --force
这应该会显示类似于以下的输出(可能会根据您现有的 Angular 版本而有所不同):
以下是我更新后的 package.json 文件,升级后: