75

I'm new in Angular 4 and I am getting this error,

Your global Angular CLI version (6.0.1) is greater than your local
version (1.4.1). The local Angular CLI version is used.

Can you please help me solving this ?

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
Mukesh Prajapati
  • 786
  • 1
  • 6
  • 12
  • Check this https://stackoverflow.com/questions/44759621/install-specific-version-of-ng-cli – Vikas May 16 '18 at 06:10
  • 1
    Are you sure you need it? Global is used to start new projects meanwhile local is responsible for current project. – Sergey May 16 '18 at 06:14

5 Answers5

86
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@1.4.1
Ritwick Dey
  • 18,464
  • 3
  • 24
  • 37
33

Quick fix :

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@1.4.1

Explanation :

If you want remove this warning, then you can downgrade your global angular-cli installation to eg. 1.4.1 by running above commands on terminal:

Complete Upgrade and Downgrade guide is on GitHub README.

Your project always uses CLI version on which you have created the project. You can see it in the warning while running ng serve.

If global version is greater than Local version then local version is used.

It is also defined in your package.json file.

"devDependencies": {
    "@angular/cli": "1.5.0",
     ....
} 

CLI warning

Reference Link

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
9

1) Do you have other projects which are using angular (and what version of CLI are they using)

2) Once you identify which version you want to retain, you can uninstall the current version by

global:

npm uninstall -g @angular/cli

or local

npm uninstall @angular/cli

3) Then install desired version in the same scope as you uninstalled (making sure of any dependencies with other components)

global

specific version

npm install -g @angular/cli@1.4.1

latest version

npm install -g @angular/cli

local Same as global but without the "-g" flag

Ideally the versions should be latest unless you figure out any compatibility issues

Edit:

Angular CLI 6.xxx

has a breaking change of "angular.json" in new vs ".angular.json" in old (difference of dot in file name). Use Error: Local workspace file ('angular.json') could not be found if moving to angular 6

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
NitinSingh
  • 2,029
  • 1
  • 15
  • 33
  • 3
    after this i am getting this error: Local workspace file ('angular.json') could not be found. – Mukesh Prajapati May 16 '18 at 06:45
  • 3
    i check by ng -version and ng -version --global then both version is now 6.0.1 – Mukesh Prajapati May 16 '18 at 06:50
  • Hi Mukesh, sorry for the trouble, but in latest angular cli 6, they had this as breaking change (although these are the generic commands for updating all modules – NitinSingh May 17 '18 at 05:25
  • @MukeshPrajapati Follow this (more specific to current release) https://stackoverflow.com/questions/49810580/error-local-workspace-file-angular-json-could-not-be-found – NitinSingh May 17 '18 at 05:26
5

Do the following to Downgrade/Upgrade

  1. npm uninstall -g @angular/cli

  2. #Install npm-check-updates

    $ npm i -g npm-check-updates

  3. npm cache clean --force

    If you get error do it manually as below:

    open run , enter %appdata%

    enter image description here

  4. Specify which version you want to install

    npm install -g @angular/cli@x.x.x

    This will get the latest cli version:

    npm install -g @angular/cli

  • My problem was different to the OP's problem, but I had to redo all the above steps without the -g parameter to get working. – Graham Laight Feb 14 '23 at 13:52
3

I got the same warning:

Your global Angular CLI version (11.0.6) is greater than you local version (11.0.5).

So before unisntalling the old version or downgrading, I took the basic command:

ng update @angular/cli @angular/core

By updating these packages from the registry, the warning was gone and my current project was updated to the latest version.

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
Domiserver
  • 441
  • 6
  • 11