This article's content
Updating Nx and its dependencies
nx
nx

Updating to the latest version of Nx involves these steps.

Step 1: fetch latest nrwl/workspace package

nx migrate latest or to a specific version with nx migrate @nrwl/workspace@version

This fetches the specified version of the @nrwl/workspace package, analyzes the dependencies and fetches all the dependent packages. This will also update the package.json and create a migrations.json file if there are pending migrations.

At this point, no packages have been installed, and no other files have been touched. Now, you can inspect package.json to see if the changes make sense. Sometimes the migration can update a package to a version that is either not allowed or conflicts with another package. Feel free to manually apply the desired adjustments.

Step 2: Install dependencies and run migrations

yarn

nx migrate --run-migrations

Each Nx plugin is able to provide a set of migrations which are relevant to particular versions of the package, and so migrations.json (generated in step 1) will only contain migrations which are appropriate for the update you are currently applying. This command will update your source code, but leaves committing the changes up to you unless you add --create-commits.

Step 3: Cleanup

After you run all the migrations, you can remove migrations.json and commit any outstanding changes.

About Author

Mathias Bothe To my job profile

I am Mathias, born 40 years ago in Heidelberg, Germany. Today I am living in Munich and Stockholm. I am a passionate IT freelancer with more than 16 years experience in programming, especially in developing web based applications for companies that range from small startups to the big players out there. I am founder of bosy.com, creator of the security service platform BosyProtect© and initiator of several other software projects.