-1

I've been working on an Angular 8 website for a while and now I'm about to start a new website and I want to make sure I'm using the newest available version of Angular but when I use the CLI to create a new website it seems to do it in a mix of 8 and 10.
I keep seeing this error message when I try to generate the new website: Your global Angular CLI version (10.0.2) is greater than your local version (8.3.22). The local Angular CLI version is used.

What can I do to get everything on version 10?

This is the result of "ng --version"

Your global Angular CLI version (10.0.2) is greater than your local
version (8.3.22). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.22
Node: 12.14.1
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.22
@angular-devkit/core         8.3.22
@angular-devkit/schematics   8.3.22
@angular/cli                 8.3.22
@schematics/angular          8.3.22
@schematics/update           0.803.22
rxjs                         6.4.0

If I navigate right out of the folder where I want to create my project I get this when I run ng --version

Angular CLI: 10.0.2
Node: 12.14.1
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1000.2
@angular-devkit/core         10.0.2
@angular-devkit/schematics   10.0.2
@schematics/angular          10.0.2
@schematics/update           0.1000.2
rxjs                         6.5.5
fosbie
  • 852
  • 1
  • 11
  • 21
  • Maybe you just need to upgrade your Angular CLI version. Does this post help you ? https://stackoverflow.com/questions/43931986/how-to-upgrade-angular-cli-to-the-latest-version – Emilien Jul 13 '20 at 15:56
  • `when I use the CLI to create a new website...` ← What is the root directory you are doing this from (assuming you are using `ng new`). Make sure this folder is empty **and** not rooted in another project folder where you are using angular. Also it seems your global cli is already at 10 based on the message but check it just in case. – Igor Jul 13 '20 at 15:56
  • If you want to upgrade the local version (project folder) you have to install new Angular CLI – Able Alias Jul 13 '20 at 15:59
  • please run the command `ng --version` on your cmd other than any old project directory. – Durgesh Pal Jul 13 '20 at 16:00
  • Just added the extra version details – fosbie Jul 13 '20 at 16:03
  • Thanks to this post I've solved the issue. https://stackoverflow.com/questions/50894761/why-does-npm-install-local-packages-in-my-home-directory Turns out I've previously installed packages to my home directory. As soon as I deleted the node modules and package-lock.json file from C:\Users\MyUsername everything started behaving as expected! Thanks for your help – fosbie Jul 14 '20 at 08:42

3 Answers3

0

For global First uninstall Angular CLI globally by using the command

npm uninstall -g angular-cli

then install globally by using the command

npm install -g @angular/cli

if you want to do it in locally (a single project) run the same command in the project folder without -g.

Able Alias
  • 3,824
  • 11
  • 58
  • 87
0

If you are working on the same Angular 8 website but have upgraded only the CLI to v10, then you might face this issue. You need to update your current local version of you project using

ng update @angular/core @angular/cli

If you are trying to generate a new project, you shouldn't get any issue. But in case if you are still getting the issue, the best way is to uninstall your cli and install again.

to uninstall:

npm uninstall -g @angular/cli
npm cache clean --force

Update Node to the latest

Reinstall your angular Cli

npm install -g @angular/cli@latest

and then try generating a new project

Please note -g is important, currently, when installing latest Angular CLI, you may have missed -g (means global)

Amod Shinde
  • 144
  • 9
  • I've just tried all of the steps and it's still the same. Also I've created a new folder for the project and it's still showing 8 when I do ng --version – fosbie Jul 13 '20 at 16:20
0

It's actually very simple..

first check which version you have install globally by typing the following command

npm list -g --depth=0

make sure you have angular 10.x.x but if not then uninstall the old angular cli version and re install it globally using the following command

npm install -g @angular/cli

after doing so you can start a new project using the following command

ng new "your app name"

later move your src folder to the new project you just created and run

ng serve

good luck!

user12163165
  • 555
  • 8
  • 12
  • When I run the npm list command I get this, which looks like there might be some issues.+-- @angular/cli@10.0.2 +-- @angular/core@10.0.3 +-- UNMET PEER DEPENDENCY rxjs@^6.5.3 `-- UNMET PEER DEPENDENCY zone.js@~0.10.3 npm ERR! peer dep missing: rxjs@^6.5.3, required by @angular/core@10.0.3 npm ERR! peer dep missing: zone.js@~0.10.3, required by @angular/core@10.0.3 – fosbie Jul 13 '20 at 16:22
  • I would remove all packages installed globally one by one and then clean the npm cache using the command "npm cache clean --force" later check to see that the cache entry is empty by typing the command "npm cache verify".. after that go step by step as I wrote it should solve your issue – user12163165 Jul 13 '20 at 17:40