Upgrading Angular in 2022

Viewed 324

I read https://update.angular.io/?v=12.0-13.0 So in Visual Studio

npx @angular/cli@13 update @angular/core@13 @angular/cli@13

All looks good, but I am confused by various versions listed in various places.

> ng v

Shows

...
Angular CLI: 13.2.3
Node: 14.18.0
Package Manager: npm 6.14.15
OS: win32 x64

Angular: 13.2.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.3
@angular-devkit/build-angular   13.2.3
@angular-devkit/core            12.1.4
@angular-devkit/schematics      12.1.4
@angular/cli                    13.2.3
@schematics/angular             12.1.4
rxjs                            6.6.7
typescript                      4.5.5

Hmm, I guess all those 12 are okay, but I don't know. Are they? Should I upgrade and how do I upgrade them?

But if I try

> npm outdated -g
Package       Current   Wanted  Latest  Location
@angular/cli   12.2.4  12.2.16  13.2.3  global

Outside of Visual Studio I'm told ng is using a version 12.

> ng v
Angular CLI: 12.2.4
[...]
Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1202.4 (cli-only)
@angular-devkit/core         12.2.4 (cli-only)
@angular-devkit/schematics   12.2.4 (cli-only)
@schematics/angular          12.2.4 (cli-only)

Why does two different ng v commands and npm outdated appear to differ (or maybe my understanding of the ng v isn't correct) and what might I do to straighten these things out so I can use all the latest stuff?

1 Answers

You can have two different versions in two places (the local project and globally), and that is normal.

The reason is that you have installed Angular once globally (The version which is displayed when you run ng v anywhere, but the local project) and when you create a new project with ng new the global version will be taken, but will have separate node_modules which is local for just the new project created.

Now if you update the version in the project you have created, that will update only the local version for that project, the global Angular version will remain the same.

In order to update the global version, you can achieve with the same command but just with -g as an argument.

And the answer to your latest question:

ng v run outside of the local project gives the same results as npm outdated -g - consider the global version.

ng v run inside the local project should give the same results as npm outdated run inside the local project - consider the local project version.

Related