拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 尝试将Angular5.2项目升级到Angular6或将Angular5.2项目升级到Angular11时出错

尝试将Angular5.2项目升级到Angular6或将Angular5.2项目升级到Angular11时出错

白鹭 - 2022-01-26 2122 0 0

任何帮助或提示将不胜感激。我安装了 Angular CLI13.1.2和 NODE14.17以及 NPM 6.14.13

我有一个使用 Angular CLI1.7.3和 Angular的 Angular 项目5.2我运行以下命令尝试将项目升级到 Angular 6 或 Angular 11,但出现以下错误:

                C:\workspace-sts-EAPV-Angular11\client>ng update @angular/core@6 @angular/cli@6
            Your global Angular CLI version (13.1.2) is greater than your local version (1.7.3). The local Angular CLI version is used.

            To disable this warning use "ng config -g cli.warnings.versionMismatch false".
            Error: Unexpected end of JSON input
            Unexpected end of JSON input

            C:\workspace-sts-EAPV-Angular11\client>ng update @angular/cli @angular/core
            Your global Angular CLI version (13.1.2) is greater than your local version (1.7.3). The local Angular CLI version is used.

            To disable this warning use "ng config -g cli.warnings.versionMismatch false".
            Error: Unexpected end of JSON input
            Unexpected end of JSON input

这是我的 package.json 档案:

{
  "name": "eApprovals",
  "description": "Online eApprovals for ontario ministry",
  "homepage": "https://www.ontario.ca",
  "private": true,
  "version": "1.0.0",
  "license": "on.ca",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --host 0.0.0.0 --disable-host-check --proxy-config proxy.conf.json",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "dependencies": {
    "@angular/animations": "5.2.0",
    "@angular/common": "5.2.0",
    "@angular/compiler": "5.2.0",
    "@angular/core": "5.2.0",
    "@angular/forms": "5.2.0",
    "@angular/http": "5.2.0",
    "@angular/platform-browser": "5.2.0",
    "@angular/platform-browser-dynamic": "5.2.0",
    "@angular/router": "5.2.0",
    "@ngrx/core": "1.2.0",
    "@ngrx/store": "5.0.0",
    "adal-angular": "^1.0.17",
    "adal-angular4": "2.0.16",
    "angular2-text-mask": "8.0.4",
    "bootstrap": "3.3.7",
    "chart.js": "2.8.0",
    "core-js": "2.4.1",
    "eventsource": "^1.0.7",
    "font-awesome": "4.7.0",
    "immutable": "3.8.2",
    "jquery": "^3.4.1",
    "lodash": "^4.17.15",
    "mydatepicker": "1.6.18",
    "rxjs": "5.5.6",
    "systemjs": "0.19.46",
    "zone.js": "0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "1.7.3",
    "@angular/compiler-cli": "5.2.0",
    "@angular/language-service": "5.2.0",
    "@types/jasmine": "2.8.3",
    "@types/jasminewd2": "2.0.2",
    "@types/jquery": "2.0.40",
    "@types/lodash": "4.14.59",
    "@types/node": "6.0.60",
    "codelyzer": "4.0.1",
    "jasmine-core": "2.8.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "2.0.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.2.1",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "protractor": "5.1.2",
    "ts-node": "4.1.0",
    "tslint": "5.9.1",
    "typescript": "2.9.1"
  }
}

我究竟做错了什么?任何帮助或提示将不胜感激!

uj5u.com热心网友回复:

我建议你可以按照这个指南来升级你的项目:

  1. 使用最新的 Angular CLI 创建一个新项目。

    ng new newproject --routing --style css
    cd newproject
    
  2. 从生成的项目中洗掉 src。

    rm -rf src/
    
  3. 将您的旧项目复制src/到此处。

    cp -r your_old_project/src .
    
  4. 尝试构建您的项目并修复所有错误。

    ng build --configuration production
    

uj5u.com热心网友回复:

这些是简单的警告,告诉您机器中安装的 angular cli 版本是 13,而您的项目中本地使用的是 1.7。

这些警告只是让你知道它没什么可做的。

我建议使用https://update.angular.io 中的指南,然后从目标版本中进行选择。最好一次升级一个主要版本。然后去下一个专业。否则,如果您的项目很复杂,它会一次性处理大量错误。

PS:它包括禁用这些警告的命令。

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *