angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Your global Angular CLI version is greater than your local

Open probert94 opened this issue 9 years ago • 23 comments

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Windows 10 x64 Node 8.5.0 Angular CLI 1.5.0

Repro steps.

  1. Create project with older CLI-Version (in my case 1.3.1).
  2. Update CLI-Version (in my case to 1.5.0).
  3. Run ng --version in a folder outside the 1.3.1-Project.

The log given by the failure.

Your global Angular CLI version (1.5.0) is greater than your local version (1.3.1). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false". @angular/cli: 1.3.1 node: 8.5.0 os: win32 x64

Desired functionality.

The ng-commands should only use a local version, if I am inside a cli-project.
Anywhere else it should use the global (1.5.0) version.

Mention any other details that might be useful.

I have multiple CLI-Projects with different versions (most of them are older test projects which I did not update) in different locations on the hard drive.
For some reason the ng-commands (ng -v, ng new etc.) take one of the locally installed cli-versions, no matter in which folder I execute it.
I couldn't even find which "local" version it used.
Running where ng only returned the global installation under AppData\Roaming.
Reinstalling cli (npm uninstall -g @angular/cli, npm cache clear --force, npm install @angular/cli) did not solve the issue for me.

Am I missing something or is this a bug?

probert94 avatar Nov 02 '17 10:11 probert94

If I had to bet, you have multiple global node modules somewhere in your system. I've seen other similar reports on windows. Maybe you also have a node_modules somewhere up in the path of where you are running these commands?

It's hard to tell. But we don't have any code to go use a specific CLI version inside specific projects.

I'd check your environment path to see how many node folders are there. Maybe there's a couple of them from older installs.

filipesilva avatar Nov 02 '17 14:11 filipesilva

@filipesilva thank you very much for the fast answer.
I executed where ng command and it listed only one istallation, so I thought thats the only installation. But I'll check it again tomorrow and let you know if I found anything.
Btw. Is it possible to get the path of the used ng version (global or local)?

probert94 avatar Nov 02 '17 18:11 probert94

Not that I can think of... We don't have any command that lists the CLI location.

filipesilva avatar Nov 02 '17 19:11 filipesilva

@filipesilva I checked it again and you were right.
I had a Angular-CLI installation inside my user dir. As soon as I removed it, everything worked as expected.
Sorry for any inconvenience and thank you for the quick help :)

probert94 avatar Nov 03 '17 07:11 probert94

Glad to hear that's sorted. Npm problems are often hard to get to the bottom of.

filipesilva avatar Nov 03 '17 12:11 filipesilva

I had the exact same issue, It is a very confusing situation -- thanks for the guidance.

ckapilla avatar Nov 04 '17 13:11 ckapilla

@Springrbua where/how did you locate? Having the same issue but unsure how you solved? Thanks!

chuckjgray avatar Nov 06 '17 23:11 chuckjgray

I just checked my home dir, as I sometimes accidentaly run npm install in that dir.
I then only removed the node_modukes from there.

probert94 avatar Nov 07 '17 11:11 probert94

I have very simple answer , please issue the below command to resolve the problem npm install --save-dev @angular/cli@latest

it will update your local cli version.

varadharaj01 avatar Dec 21 '17 17:12 varadharaj01

@varadharaj01 I believe you are misunderstanding the problem. It wasn't the local version that was the problem, it was a somewhat "hidden" global version somewhere in the

ckapilla avatar Dec 21 '17 17:12 ckapilla

@varadharaj01 where do I this? In the folder where the Angular code is present?

niteshkejriwal avatar Jan 10 '18 07:01 niteshkejriwal

In my case, I had angular-cli globally installed as 1.6.5 version, however the project I was trying to run had "@angular/cli": "1.6.3" in "devDependencies": { ... } of it's package.json file.

since we install all the dependencies of the project, to run / serve of any project, two different versions of ng-cli were accessible inside of that specific project for me. that's why I was getting this error.

solved the issue by changing the version from 1.6.3 to 1.6.5 in package.json of the project, and running npm i or yarn install.

Cheers !

shahzadns avatar Jan 21 '18 00:01 shahzadns

I also sorted by deleting the node_modules folder and doing a fresh npm install

niteshkejriwal avatar Jan 21 '18 06:01 niteshkejriwal

Thank you. Saves me tons of time.

ganga-ai avatar Jan 26 '18 17:01 ganga-ai

I have the same message when executing ng serve. My console throws this :

Your global Angular CLI version (1.6.6) is greater than your local version (1.6.2). The local Angular CLI version is used.

This doesn't prevent me from executing ng serve and launching my website, but I'd like to fix this. I tried to follow the here above advice, but still running into the same error message.

Otherwise, I don't have the problem when launching other angular CLI projects, this appears only for one of my projects.

asmi77 avatar Jan 27 '18 12:01 asmi77

You have to update the version of angular-cli in your package.json Run either

  • yarn add exact @angular/cli --dev
  • npm install --save-dev angular-cli

cykeromens avatar Feb 06 '18 13:02 cykeromens

Finally updating my angular local version with npm install --save-dev @angular/cli@latest, and running npm install after removing node_modules AND package-lock.json did the trick. Thanks :)

asmi77 avatar Feb 08 '18 14:02 asmi77

@varadharaj01 thanks

npm install --save-dev @angular/cli@latest

works for me.

davecar21 avatar Feb 22 '18 13:02 davecar21

npm install --save-dev @angular/cli@latest

ran at the project location worked for me as well.

medmison avatar Mar 04 '18 03:03 medmison

Also, another good approach which I use is to remove the cli globally and use it locally. Hopefully npx allows us to do this:

To create a new project:

npx -p @angular/cli ng new hello-world-project

Then to create a new component for example:

npx ng generate component my-component

https://medium.com/@starikovs/how-to-use-angular-cli-locally-729dbb6707dd

starikovs avatar May 12 '18 09:05 starikovs