存储库不干净。请提交或隐藏任何更改,然后在角8中更新

错误

存储库不干净。请在更新之前提交或隐藏任何更改

当我已经更新从版本7角8。

升级 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

在谷歌之后,我有这是发生在角8之后。

臭虫

Https://github.com/angular/angular-cli/issues/14600

196238 次浏览

是角度8的一个窃听器

你可以使用以下方法来解决这个问题:

ng update @angular/cli @angular/core --allow-dirty

我已经尝试使用提及命令从角8升级到角9,但仍然得到错误。

然后我尝试了同样的命令-,力旗,它为我工作。

ng update @angular/cli @angular/core --allow-dirty --force

我也有同样的问题。这是角8的常见病毒。您可以简单地使用脏命令来绕过回购检查,例如(如果您确实需要绕过这个命令,请执行强制命令)

ng update @angular/cli @angular/core --allow-dirty or
ng update @angular/cli @angular/core --allow-dirty --force

但是,我没有这样做。我按照下面的步骤..。

首先,仔细检查是否在 update.then 之前提交了所有更改,然后将项目的一个副本保存到相同的位置,并将该副本也提交到 Git。然后从原始项目目录运行以下命令

ng update @angular/core@8 @angular/cli@8

之后你可以删除副本。这对我有用! 谢谢!

首先,如果是,检查代码中是否有没有推送到 git 的更改,然后关闭旧实例(cmd)并打开 cmd 的一个新实例,然后运行命令。 这招对我很管用,谢谢

在我的例子中,这是由于 node _ module 文件夹没有被。吉蒂诺尔。一旦添加,这个错误不再出现

它可能在许多情况下出现。只需提交或隐藏任何更改,然后再次运行该命令。

对我有用

sudo npm update @angular/cli @angular/core --allow-dirty --legacy-peer-deps

以下是我将 Angular 13项目升级到 Angular 14(2022年10月)的步骤:

在项目目录中,打开具有管理权限的命令提示符,然后运行以下命令:

ng update @angular/core@14 @angular/cli@14 --allow-dirty --force

这应该显示一个类似于下面的输出(可能会有所不同,根据您现有的角度版本) :

The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 14.2.5 to perform the update.
√ Package successfully installed.
Repository is not clean. Update changes will be mixed with pre-existing changes.
Using package manager: npm
Collecting installed dependencies...
Found 23 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency @angular-devkit/build-angular @ "14.2.5" (was "13.2.6")...
Updating package.json with dependency @angular/cli @ "14.2.5" (was "13.2.6")...
Updating package.json with dependency @angular/compiler-cli @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency typescript @ "4.8.4" (was "4.5.5")...
Updating package.json with dependency @angular/animations @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/common @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/compiler @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/core @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/forms @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/platform-browser @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "14.2.5" (was "13.2.7")...
Updating package.json with dependency @angular/router @ "14.2.5" (was "13.2.7")...
UPDATE package.json (1068 bytes)
√ Packages successfully installed.
** Executing migrations of package '@angular/cli' **


> Remove 'defaultProject' option from workspace configuration.
The project to use will be determined from the current working directory.
UPDATE angular.json (3177 bytes)
Migration completed.


> Remove 'showCircularDependencies' option from browser and server builders.
Migration completed.


> Replace 'defaultCollection' option in workspace configuration with 'schematicCollections'.
Migration completed.


> Update Angular packages 'dependencies' and 'devDependencies' version prefix to '^' instead of '~'.
UPDATE package.json (1068 bytes)
√ Packages installed successfully.
Migration completed.


> Remove 'package.json' files from library projects secondary entrypoints.
Migration completed.


> Update TypeScript compilation target to 'ES2020'.
UPDATE tsconfig.json (863 bytes)
Migration completed.


** Executing migrations of package '@angular/core' **


> As of Angular version 13, `entryComponents` are no longer necessary.
Migration completed.


> In Angular version 14, the `pathMatch` property of `Routes` was updated to be a strict union of the two valid options: `'full'|'prefix'`.
`Routes` and `Route` variables need an explicit type so TypeScript does not infer the property as the looser `string`.
Migration completed.


> As of Angular version 14, Forms model classes accept a type parameter, and existing usages must be opted out to preserve backwards-compatibility.
Migration completed.

下面是升级后更新的 package.json 文件:

{
"name": "custom-project-14",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^14.2.5",
"@angular/common": "^14.2.5",
"@angular/compiler": "^14.2.5",
"@angular/core": "^14.2.5",
"@angular/forms": "^14.2.5",
"@angular/platform-browser": "^14.2.5",
"@angular/platform-browser-dynamic": "^14.2.5",
"@angular/router": "^14.2.5",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.2.5",
"@angular/cli": "^14.2.5",
"@angular/compiler-cli": "^14.2.5",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.8.4"
}
}