nx: nx migrate @angular/core doesn't update all packages

Current Behavior

running nx migrate @angular/coreonly updates package.json for @angular/core and not for all other @angular packages

Expected Behavior

The behavior should be the same as when calling ng update @angular/core

Environment

Node : 14.16.0 OS : darwin x64 npm : 6.14.11

nx : Not Found @nrwl/angular : 12.2.0 @nrwl/cli : 12.2.0 @nrwl/cypress : 12.2.0 @nrwl/devkit : 12.2.0 @nrwl/eslint-plugin-nx : 12.2.0 @nrwl/express : Not Found @nrwl/jest : 12.2.0 @nrwl/linter : 12.2.0 @nrwl/nest : 12.2.0 @nrwl/next : Not Found @nrwl/node : 12.2.0 @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 12.2.0 @nrwl/web : 12.2.0 @nrwl/workspace : 12.2.0 @nrwl/storybook : Not Found @nrwl/gatsby : Not Found typescript : 4.1.5

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 18
  • Comments: 19 (1 by maintainers)

Most upvoted comments

Before:

ng update @angular/core @angular/cli

After:

nx migrate latest
nx migrate @nrwl/nx-cloud
nx migrate @angular-devkit/build-angular
nx migrate @angular/animations
nx migrate @angular/cdk
nx migrate @angular/cli
nx migrate @angular/common
nx migrate @angular/compiler
nx migrate @angular/compiler-cli
nx migrate @angular/core
nx migrate @angular/flex-layout
nx migrate @angular/forms
nx migrate @angular/language-service
nx migrate @angular/material
nx migrate @angular/platform-browser
nx migrate @angular/platform-browser-dynamic
nx migrate @angular/router
nx migrate @angular/service-worker
nx migrate @angular/animations
nx migrate @angular/common
nx migrate @angular/compiler
nx migrate @angular/core
nx migrate @angular/forms
nx migrate @angular/localize
nx migrate @angular/platform-browser
nx migrate @angular/platform-browser-dynamic
nx migrate @angular/router

nx migrate --run-migrations=migrations.json

And it’s much slower as well as you have to wait for each run separately. As I said in Slack it would at least help if you could run them in a single command:

nx migrate @angular-devkit/build-angular @angular/animations @angular/cdk @angular/cli @angular/common @angular/compiler @angular/compiler-cli @angular/core @angular/flex-layout @angular/forms @angular/language-service @angular/material @angular/platform-browser @angular/platform-browser-dynamic @angular/router @angular/service-worker @angular/animations @angular/common @angular/compiler @angular/core @angular/forms @angular/localize @angular/platform-browser @angular/platform-browser-dynamic @angular/router @nrwl/nx-cloud 

Or support something like:

nx migrate @angular/*

The workaround is just:

nx migrate latest
FORCE_NG_UPDATE=true ng update @angular/core @angular/cli 

Same happens for nx migrate latest. As far as I can tell it does not update any other packages (even @nrwl ones) as long as the @nrwl/workspace package is already up to date. I tested that by manually downgrading @nrwl/workspace and then running yarn nx migrate latest. And voila, all related packages are now actually checked for the latest version.

Output before with @nrwl/workspace@12.9.0

$ nx migrate latest
Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@latest
Fetching @nrwl/workspace@12.9.0

>  NX  The migrate command has run successfully.

- package.json has been updated
- there are no migrations to run, so migrations.json has not been created.

>  NX  Next steps:

- Make sure package.json changes make sense and then run 'yarn'
- To learn more go to https://nx.dev/latest/core-concepts/updating-nx
- You may run "nx connect-to-nx-cloud" to get faster builds, Github integration, and more. Check out https://nx.app
Done in 29.14s.

Output after downgrade of only @nrwl/workspace to @12.7.2

$ nx migrate latest
Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@latest
Fetching @nrwl/angular@12.9.0
Fetching @nrwl/cypress@12.9.0
Fetching @nrwl/eslint-plugin-nx@12.9.0
Fetching @nrwl/linter@12.9.0
Fetching @nrwl/storybook@12.9.0
Fetching @nrwl/workspace@12.9.0

>  NX  The migrate command has run successfully.

- package.json has been updated
- there are no migrations to run, so migrations.json has not been created.

>  NX  Next steps:

- Make sure package.json changes make sense and then run 'yarn'
- To learn more go to https://nx.dev/latest/core-concepts/updating-nx
- You may run "nx connect-to-nx-cloud" to get faster builds, Github integration, and more. Check out https://nx.app
Done in 99.17s.

Output after downgrade of only @nrwl/workspace and @nrwl/angular to @12.7.2

$ nx migrate latest
Fetching meta data about packages.
It may take a few minutes.
Fetching @nrwl/workspace@latest
Fetching @nrwl/angular@12.9.0
Fetching @nrwl/cypress@12.9.0
Fetching @nrwl/eslint-plugin-nx@12.9.0
Fetching @nrwl/linter@12.9.0
Fetching @nrwl/storybook@12.9.0
Fetching @ngrx/store@~12.4.0
Fetching @ngrx/effects@~12.4.0
Fetching @ngrx/entity@~12.4.0
Fetching @ngrx/router-store@~12.4.0
Fetching @ngrx/store-devtools@~12.4.0
Fetching @ngrx/component-store@~12.4.0
Fetching @angular/cli@~12.2.0
Fetching @angular-devkit/build-angular@~12.2.0
Fetching @angular-devkit/build-optimizer@^0.1202.0
Fetching @angular/core@^12.2.0
Fetching @angular/common@^12.2.0
Fetching @angular/forms@^12.2.0
Fetching @angular/compiler@^12.2.0
Fetching @angular/compiler-cli@^12.2.0
Fetching @angular/platform-browser@^12.2.0
Fetching @angular/platform-browser-dynamic@^12.2.0
Fetching @angular/platform-server@^12.2.0
Fetching @angular/router@^12.2.0
Fetching @angular/upgrade@^12.2.0
Fetching @angular/language-service@^12.2.0
Fetching @angular/animations@^12.2.0
Fetching ng-packagr@~12.2.0
Fetching typescript@~4.3.5
Fetching @nrwl/workspace@12.9.0
Fetching @ngrx/store@12.4.0
Fetching @ngrx/effects@12.4.0
Fetching @ngrx/entity@12.4.0
Fetching @ngrx/router-store@12.4.0
Fetching @ngrx/store-devtools@12.4.0
Fetching @ngrx/component-store@12.4.0
Fetching @angular/cli@12.2.7
Fetching @angular-devkit/build-angular@12.2.7
Fetching @angular-devkit/build-optimizer@0.1202.0
Fetching @angular/core@12.2.0
Fetching @angular/common@12.2.0
Fetching @angular/forms@12.2.0
Fetching @angular/compiler@12.2.0
Fetching @angular/compiler-cli@12.2.0
Fetching @angular/platform-browser@12.2.0
Fetching @angular/platform-browser-dynamic@12.2.0
Fetching @angular/platform-server@12.2.0
Fetching @angular/router@12.2.0
Fetching @angular/upgrade@12.2.0
Fetching @angular/language-service@12.2.0
Fetching @angular/animations@12.2.0
Fetching ng-packagr@12.2.2
Fetching typescript@4.3.5

>  NX  The migrate command has run successfully.

- package.json has been updated
- migrations.json has been generated

>  NX  Next steps:

- Make sure package.json changes make sense and then run 'yarn'
- Run 'nx migrate --run-migrations'
- To learn more go to https://nx.dev/latest/core-concepts/updating-nx
- You may run "nx connect-to-nx-cloud" to get faster builds, Github integration, and more. Check out https://nx.app
Done in 219.90s.

So it also seems like when any package in the list fulfills the version held by nx, the update process just stops.

Not sure if somehow the way dependency update work has changed, but documentation should also be updated in that case. Because currently it does say:

Not only does nx migrate update you to the latest version of Nx, but it also updates the versions of dependencies that we support and test such as Jest and Cypress.

Which obviously does not seem to be the case anymore. But as Nx still acts as a wrapper, it should in my opinion actually update all dependencies. Or at least it should give an option to force update check on all dependencies.

If my findings are not related to this issue, please to tell me, as I would create a separate issue for this then.

So I guess the real workaround is this snippet:

nx migrate latest
npm i
nx migrate --run-migrations=migrations.json
nx migrate @nrwl/nx-cloud
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular-devkit/build-angular
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/animations
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/cdk
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/cli
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/common
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/compiler
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/compiler-cli
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/core
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/flex-layout
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/forms
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/language-service
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/material
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/platform-browser
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/platform-browser-dynami
npm ic
nx migrate --run-migrations=migrations.json
nx migrate @angular/router
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/service-worker
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/animations
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/common
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/compiler
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/core
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/forms
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/localize
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/platform-browser
npm i
nx migrate --run-migrations=migrations.json
nx migrate @angular/platform-browser-dynami
npm ic
nx migrate --run-migrations=migrations.json
nx migrate @angular/router
npm i
nx migrate --run-migrations=migrations.json

Then get a coffee… or two

Does not work for me unfortunately

npx nx@latest migrate latest

migrated all Nx deps from 15.0.0 to 15.7.0, ran a bunch of migrations but completely ignored that I am on Angular 14

However, running nx migrate @angular/cli core, etc. updates the deps, adds migrations but some fail due to a migration setup error (probably because there’s no angular.json anymore?)

Anything I can do about this?

Update: Found something here https://nx.dev/recipes/other/advanced-update#updating-dependencies-that-are-behind-the-versions-nx-manages

nx migrate latest --from=nx@14

did the trick for me

This is now supported! 🎉

@KimBum that sounds like a feasible hackaround - how did you do the downgrade?

The following was not enough for me:

nx migrate @nrwl/workspace@12.7.2
nx migrate @nrwl/angular@12.7.2

I quite literally changed the version inside package.json to 12.7.2, did yarn install and then started yarn nx migrate latest. Although I did notice, that this would of course only update whatever their dependency tree is and nothing further 😞

Generally yarn and ng themselves seem to discourage full dependency updates, so that might be one reason. It would probably be best to wait for the aforementioned feature ticket to be resolved.

Just saw this has been heavily requested for a while now. They created a feature request for it earlier this year (#4575), but nothing has happened yet.