存储库不干净。请在 Angular 8 中更新之前提交或存储任何更改

新手上路,请多包涵

错误

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

当我从版本 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 许可协议

阅读 1.3k
1 个回答

以下内容对我将 Angular 13 项目升级到 Angular 14(2022 年 10 月)有用:

在您的项目目录中,使用管理员权限打开命令提示符。然后运行以下命令:

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

这应该会显示类似于以下的输出(可能会根据您现有的 Angular 版本而有所不同):

 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"
  }
}

原文由 Devner 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题