This version of CLI is only compatible with Angular version 5.0.0 or higher error
Asked Answered
C

5

13

I already had angular project that ran in 4 version. While installing new project, unfortunately i have installed 6 version of angular cli. This throw me an error 'Your global Angular CLI version is greater than your local version' while running ng serve command in old project that ran in 4 version. Again i tried to update my anglar local version. But now i have got an error This version of CLI is only compatible with Angular version 5.0.0 or higher. My package.json is following:

 {
  "name": "authority-client",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/core": "^0.7.2",
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "@types/file-saver": "^1.3.0",
    "angular2-cookie": "^1.2.6",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.8",
    "ng2-toastr": "^4.1.2",
    "ngx-bootstrap": "^2.0.1",
    "ngx-loading": "^1.0.14",
    "npm": "^5.5.1",
    "postcss-loader": "^2.0.9",
    "rxjs": "^5.4.2",
    "sweetalert2": "^7.22.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "^6.1.5",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@ngtools/webpack": "^6.1.5",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-ide": "^0.9.44",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "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.4.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

Can someone fix this error. I have been tried from last 2 days, but i cant find any appropriate solution.

Chondroma answered 5/9, 2018 at 4:4 Comment(2)
which of the two do you currently have in your projects root, angular.json or angular-cli.json ?Boesch
I have angular.jsonChondroma
C
19

I think this is what you're looking for. Other answers simply forgot to include the -g parameter.

npm install -g @angular/[email protected]

It's all said in the error itself. You're not installing it globally ;) Hope this solves your issues.

UPDATE: To update Angular CLI to a new version, you must update both the global package and your project's local package.

Global package:

npm uninstall -g @angular/cli
npm cache verify // If npm version is < 5 then use `npm cache clean`
npm install -g @angular/cli@latest

Local project package:

// Use rmdir /S/Q node_modules dist in Windows Command Prompt; 
// Use rm -r -fo node_modules, dist in Windows PowerShell

rm -rf node_modules dist 
npm install --save-dev @angular/cli@latest
npm install

For more info check out the ReadMe file on GitHub.

Capriola answered 6/9, 2018 at 2:57 Comment(3)
Thanks for help. I'm updating my global and local version of angular cli like you shown above. Now it thrown me error like this: Could not find module "@angular-devkit/build-angular"Chondroma
That package is newly introduced in Angular 6.0 ... I thought you wanted to work on an Angular 4 project?! :/Bluhm
@NabrajBhattarai - Anyways, you could install it as a dev-dependency: npm install --save-dev @angular-devkit/build-angular or/ and you can re-run npm install in your project. Additionally, you should check out your NPM version, and might as well update that too if necessaryBluhm
P
2

I had a similar problem, so I had to check the version of @angular-devkit/build-angular, I run this command:

npm list @angular-devkit/build-angular

In this way, it can be verified if any additional library such as: "npx-build-plus", is using it and, incidentally, it is updated to the version you need.

Paratuberculosis answered 31/5, 2023 at 18:53 Comment(1)
I had the same problem! Good catch!Malathion
N
1

Use CLI version 1.4.9 with angular 4.

npm install @angular/[email protected]

"devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "1.4.9",
    ....
    ....
  }

you can refer How to install Angular-CLI with Angular v4.x

Nea answered 5/9, 2018 at 4:32 Comment(1)
Now I have got a message like this: 'Your global Angular CLI version (6.1.5) is greater than your local version (1.4.9). The local Angular CLI version is used.'Chondroma
C
0

You can solve your problem by running:

npm install --save-dev @angular/cli@latest
Capitulation answered 6/9, 2018 at 1:54 Comment(0)
A
0

It happened to me while running ng from yarn. Instead write your yarn commands so they call node_modules/.bin/ng which is the version you have installed for your project. This has the benefit of not relying on a globally installed version.

Anatomical answered 24/7 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.