Home > Mobile >  Error trying to upgrade an Angular 5.2 project to Angular 6 or upgrading an Angular 5.2 project to A
Error trying to upgrade an Angular 5.2 project to Angular 6 or upgrading an Angular 5.2 project to A

Time:12-21

Any help or hint would be greatly appreciated it. I installed Angular CLI 13.1.2 and NODE 14.17 and NPM 6.14.13.

I have a Angular project which is using Angular CLI 1.7.3 and Angular 5.2. I ran the following command trying to upgrade the project to Angular 6 or Angular 11 but I get the following error:

                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

Here is my package.json file:

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

What am I doing wrong? Any help or hint would be greatly appreciated it!!

CodePudding user response:

I suggest you can following this guideline to upgrade your project:

  1. Use latest Angular CLI to create a new project.

    ng new newproject --routing --style css
    cd newproject
    
  2. Remove src from the generated project.

    rm -rf src/
    
  3. Copy your old project's src/ to here.

    cp -r your_old_project/src .
    
  4. Try to build your project and fix all the errors.

    ng build --configuration production
    

    You might deal with lots of errors because of the version difference is huge. But this way can be much easier than you upgrade Angular project from one version to next one by one.

CodePudding user response:

Those are simple warnings telling your angular cli version installed in your machine is 13 and what locally used inside your project is 1.7.

Those warnings are just to let you know about it nothing much to do.

I recommend using guide from https://update.angular.io then choose from and targeted versions. It is best to upgrade one major version at a time. Then go to next major. Otherwise it is going deal hell of errors at one shot if your project is complex.

PS: It includes the command for disable these warning.

  • Related