update an nx-angular project to a specific major version of angular
Asked Answered
S

3

16

I am a bit lost in the versioning system of nx (with angular). In my case, I want to upgrade from angular 12 to angular 13 with latest compatible tooling (jest, nx).

Agnular 14 is out now. So if I run the command below, it will update to angular 14.

nx migrate latest

How do I update to latest angular13 with latest compatible jest and other tooling?

What I do not understand is the connection between angular versions and nx versions. How are those two connected in terms of version numbers?

Best regards

Shackleford answered 29/6, 2022 at 10:15 Comment(0)
S
11

Some months later ... I found this page https://nx.dev/angular-nx-version-matrix It seems the major numbers are connected between angular and nrwl-nx.

For a list of releases of angular-nx version numbers I found this page (maybe there is a better one?): https://github.com/nrwl/nx/releases If you want the latest angular 13, you have to look at previous pages till you find the last version 13.*.

I would also like to share some experience. To migrate from 12.x to 13.10.6 did not work (but to 14 worked out of the box). What we did is migrate to 13.0 first and then 13.10.6 in a second migration.

Shackleford answered 25/9, 2022 at 14:49 Comment(2)
Just note, that nx and ng versions don't always match: e.g. nx migrate 14 will migrate to nx14 which (according to the combat-matrix uses ng13! So to update to the latest ng 14 you must use nx14.6.0 <= nx15.1.1: e.g. nx migrate 15.1.1 worked for me to update my workspace to nx15.1.1 and ng14Thorwald
thank you, this is the second time i've needed to update angular in my nx project and i forget every time that you have to update NX not angular to get a new version of angular.Colchester
P
9

Sometimes you need the very latest version of Angular and but a migration configuration is not yet available.

For instance, let's say Angular 17.1 is released on January 17, 2024, but as of today (January 22), the last available version according to the Angular and Nx Version Matrix is:

Angular Version    Nx Version
~17.0.0            17.1.0 <= latest

Maybe you have already used these commands (as recommended by Nx):

# Update Nx to the latest version
  nx update @nrwl/workspace

# Migrate Nx to the latest version
  nx migrate latest

# If migration.json is created
  nx migrate --run-migrations=migrations.json

# Update all packages to the latest version
  npm install

And this process has updated your setup to version 17.0.0, but want to use Angular 17.1 (the latest possible version) immediately.

In this scenario, you might try:

  npx npm-check-updates -u
  npm i --legacy-peer-deps

The first command updates your package.json to the latest package versions, while the second command takes care of installing the updates, respecting the necessary peer dependencies.

Using --legacy-peer-deps can help you out, by bypassing the peer deps auto-installation. It is particularly useful when dealing with version mismatches or unmeet peer dependencies.

But there is no guarantee, that can work so in each time. Better use a versioning system (e.g. git) before you try to do so.

p.s. I could successfully upgrade to Angular 17.1 today.

Phelia answered 22/1, 2024 at 15:37 Comment(2)
Bro, this is literally the SO I thought I didn't deserve. Just migrated some weeks ago our monorepo to 17.0.9 (obv, 17.1.0 includes signal inputs, rip) and I will give this a go. Thank you very much!!!Mcculloch
In my case (31 january 2024), running nx migrate latest and then the suggested command from the NX cli was enoughMcculloch
A
4

I needed to update to Angular version 15 instead of the latest (v17 at the time of writing), based on https://nx.dev/nx-api/angular/documents/angular-nx-version-matrix I was able to upgrade to the Angular specific major version using the following migration commands:

npx nx migrate 12.2.0 // Angular 11.2.0
npx nx migrate 13.1.4 // Angular 12.8.18
npx nx migrate 14.1.9 // Angular 13.3.12
npx nx migrate 14.6.0 // Angular 14.2.12
npx nx migrate 15.9.7 // Angular 15.2.10
Anorthosite answered 13/3, 2024 at 12:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.