typescript 存储库不干净,请在更新之前提交或隐藏任何更改In Angular 8

agyaoht7  于 2022-12-24  发布在  TypeScript
关注(0)|答案(8)|浏览(269)

错误
存储库不干净。请在更新前提交或隐藏任何更改
当我已经从版本7更新到Angular 8。
Angular Guide for upgrade 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

ocebsuys

ocebsuys1#

是Angular 8中的一个错误
您可以使用以下方法解决此问题:
第一个月

lo8azlld

lo8azlld2#

我已经尝试使用提及命令从Angular 8升级到Angular 9,但仍然得到错误。
然后我尝试了相同的命令--强制标记,它对我很有效。

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

bqf10yzr3#

我也遇到过同样的问题。这是Angular 8中的一个常见错误。简单地说,你可以使用脏命令来绕过repo检查,比如(如果你真的需要绕过这个,请遵循强制命令)

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

但我没有那么做我按照以下步骤。
首先,在更新之前,仔细检查你是否提交了所有的更改。然后,在相同的位置保留一个项目的副本,并将副本提交到Git。然后,从原始项目目录运行以下命令

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

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

ajsxfq5m

ajsxfq5m4#

对我有用

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

ibrsph3r5#

以下内容有助于我将Angular 13项目升级为Angular 14(2022年10月):

在项目目录中,使用管理员权限打开命令提示符,然后运行以下命令:
第一个月

这将显示类似于以下内容的输出(根据您现有的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"
  }
}
7gyucuyw

7gyucuyw6#

在我的例子中,这是由于node_modules文件夹没有被. gitignore排除。一旦添加,这个错误不再出现

u91tlkcl

u91tlkcl7#

首先,检查你的代码中是否有任何更改还没有推送到git,如果是,推送它们,然后关闭旧示例(cmd)并打开一个新的cmd示例,然后运行命令。

ioekq8ef

ioekq8ef8#

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

相关问题