Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
Use this file to discover all available pages before exploring further.
nx migrate is a two-step process:
- Update packages — resolves the new versions of Nx packages and their plugins, updates
package.json, and generates amigrations.jsonfile listing the code transformations to apply. - Apply migrations — runs the transformations listed in
migrations.jsonagainst your source files.
Run
npm install (or your package manager’s install command) after step 1 and before step 2 to install the updated packages.Migration workflow
Generate migrations.json
Target the version you want to migrate to. Using This updates
latest resolves the latest stable release:package.json and creates migrations.json.Apply the migrations
migrations.json against your workspace files.Arguments
The target package and version to migrate to (e.g.,
@nx/workspace@20.0.0, latest, @nx/react@latest).Options
Execute code migrations from a file. When no file path is provided, reads from
migrations.json in the current directory.When using
--run-migrations, continue successfully even if the migrations file does not exist.Override the currently installed versions of packages when computing which migrations to run. Useful when the installed versions are not accurate. Accepts a comma-separated list.
Override the target versions that the migrator would otherwise calculate. Accepts a comma-separated list.
Automatically create a git commit after each migration runs. Alias:
-C.Custom prefix for commit messages when
--create-commits is enabled. Requires --create-commits.Enable interactive prompts to confirm whether to collect optional package updates and migrations.
Exclude migrations that should have already been applied in earlier updates. Must be used with
--from.Print additional information about the migration process.
Examples
How migrations.json works
After runningnx migrate <version>, Nx creates (or updates) a migrations.json file:
migrations.json before running --run-migrations. Each migration is a code transform (similar to a generator) that modifies workspace files.
