Skip to content

Running migration @nx/jest: replace-removed-matcher-aliases fails with typescript error #32062

@pedroyan

Description

@pedroyan

Current Behavior

Nx migration fails from 21.2.1 to 21.3.5 when running migration @nx/jest: replace-removed-matcher-aliases with Error: TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

Expected Behavior

The migration should not fail.

GitHub Repo

pedroyan/nx-bug-repro@d8aa628

Steps to Reproduce

  1. Clone repo at the commit pedroyan/nx-bug-repro@d8aa628
  2. Run nx migrate latest
  3. Run nx migrate --run-migrations
  4. See the error

Nx Report

Node           : 22.11.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.13.1

nx (global)        : 21.1.2
nx                 : 21.3.5
@nx/js             : 21.3.5
@nx/jest           : 21.3.5
@nx/eslint         : 21.3.5
@nx/workspace      : 21.3.5
@nx/devkit         : 21.3.5
@nx/eslint-plugin  : 21.3.5
@nx/nest           : 21.3.5
@nx/next           : 21.3.5
@nx/node           : 21.3.5
@nx/playwright     : 21.3.5
@nx/plugin         : 21.3.5
@nx/react          : 21.3.5
@nx/vite           : 21.3.5
@nx/web            : 21.3.5
@nx/webpack        : 21.3.5
typescript         : 5.8.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/next/plugin
@nx/playwright/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/react/router-plugin
@nx/vite/plugin
@nx/webpack/plugin
---------------------------------------
Local workspace plugins:
@fintropya/automation
---------------------------------------
Cache Usage: 0.00 B / 185.82 GB

Failure Logs

NX   Running 'pnpm install --no-frozen-lockfile' to make sure necessary packages are installed

Scope: all 15 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 765ms using pnpm v10.13.1

 NX   Running migrations from 'migrations.json'

Running the following migrations:
- @nx/jest: rename-test-path-pattern (Rename the CLI option `testPathPattern` to `testPathPatterns`.)
- @nx/jest: replace-removed-matcher-aliases (Replace removed matcher aliases in Jest v30 with their corresponding matcher)
---------------------------------------------------------

Running migration @nx/jest: rename-test-path-pattern
Ran rename-test-path-pattern from @nx/jest
  Rename the CLI option `testPathPattern` to `testPathPatterns`.

No changes were made

---------------------------------------------------------
Running migration @nx/jest: replace-removed-matcher-aliases

 NX   Failed to run replace-removed-matcher-aliases from @nx/jest. This workspace is NOT up to date!


 NX   Jest: Failed to parse the TypeScript config file /Users/pedroyan/Project/Fintropya/fintropya/apps/backend/jest.config.ts

  TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

Pass --verbose to see the stacktrace.

nx migrate [packageAndVersion]

Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nx/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json). Use flag --if-exists to run migrations only if the migrations file exists.

Positionals:
  packageAndVersion  The target package and version (e.g, @nx/[email protected]).                                                                                     [string]

Options:
      --help                      Show help                                                                                                                         [boolean]
      --version                   Show version number                                                                                                               [boolean]
      --verbose                   Prints additional information about the commands (e.g., stack traces).                                                            [boolean]
      --runMigrations             Execute migrations from a file (when the file isn't provided, execute migrations from migrations.json).                            [string]
      --ifExists                  Run migrations only if the migrations file exists, if not continues successfully.                                [boolean] [default: false]
      --from                      Use the provided versions for packages instead of the ones installed in node_modules (e.g., --from="@nx/[email protected],@nx/[email protected]").
                                                                                                                                                                     [string]
      --to                        Use the provided versions for packages instead of the ones calculated by the migrator (e.g., --to="@nx/[email protected],@nx/[email protected]").
                                                                                                                                                                     [string]
  -C, --createCommits             Automatically create a git commit after each migration runs.                                                     [boolean] [default: false]
      --commitPrefix              Commit prefix to apply to the commit for each migration, when --create-commits is enabled.     [string] [default: "chore: [nx migration] "]
      --interactive               Enable prompts to confirm whether to collect optional package updates and migrations.                            [boolean] [default: false]
      --excludeAppliedMigrations  Exclude migrations that should have been applied on previous updates. To be used with --from.                    [boolean] [default: false]

Examples:
  migrate latest                                                           Update all Nx plugins to "latest". This will generate migrations.json
  migrate 9.0.0                                                            Update all Nx plugins to "9.0.0". This will generate migrations.json
  migrate @nx/[email protected] --from="@nx/[email protected],@nx/[email protected]"  Update @nx/workspace and generate the list of migrations starting with version 8.0.0 of
                                                                           @nx/workspace and @nx/node, regardless of what is installed locally
  migrate @nx/[email protected] --to="@nx/[email protected],@nx/[email protected]"     Update @nx/workspace to "9.0.0". If it tries to update @nx/react or @nx/angular, use version
                                                                           "9.0.1"
  migrate [email protected]                                           Update another-package to "12.0.0". This will update other packages and will generate
                                                                           migrations.json file
  migrate latest --interactive                                             Collect package updates and migrations in interactive mode. In this mode, the user will be
                                                                           prompted whether to apply any optional package update and migration
  migrate latest [email protected] --exclude-applied-migrations             Collect package updates and migrations starting with version 14.5.0 of "nx" (and Nx first-party
                                                                           plugins), regardless of what is installed locally, while excluding migrations that should have
                                                                           been applied on previous updates
  migrate --run-migrations=migrations.json                                 Run migrations from the provided migrations.json file. You can modify migrations.json and run this
                                                                           command many times
  migrate --run-migrations --create-commits                                Create a dedicated commit for each successfully completed migration. You can customize the prefix
                                                                           used for each commit by additionally setting --commit-prefix="PREFIX_HERE "

Find more information and examples at https://nx.dev/nx/migrate

Error: Command failed: pnpm exec nx _migrate --run-migrations
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:888:11)
    at execSync (node:child_process:960:15)
    at runNxSync (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/utils/child-process.js:35:34)
    at runLocalMigrate (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/command-line/migrate/migrate.js:1122:39)
    at Object.runMigration (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/command-line/migrate/migrate.js:1145:9)
    at Object.handler (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/command-line/migrate/command-object.js:13:68) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 97216,
  stdout: null,
  stderr: null
}

 NX   Command failed: pnpm exec nx migrate --run-migrations

Pass --verbose to see the stacktrace.

nx migrate [packageAndVersion]

Creates a migrations file or runs migrations from the migrations file.
- Migrate packages and create migrations.json (e.g., nx migrate @nx/workspace@latest)
- Run migrations (e.g., nx migrate --run-migrations=migrations.json). Use flag --if-exists to run migrations only if the migrations file exists.

Positionals:
  packageAndVersion  The target package and version (e.g, @nx/[email protected]).                                                                                     [string]

Options:
      --help                      Show help                                                                                                                         [boolean]
      --version                   Show version number                                                                                                               [boolean]
      --verbose                   Prints additional information about the commands (e.g., stack traces).                                                            [boolean]
      --runMigrations             Execute migrations from a file (when the file isn't provided, execute migrations from migrations.json).                            [string]
      --ifExists                  Run migrations only if the migrations file exists, if not continues successfully.                                [boolean] [default: false]
      --from                      Use the provided versions for packages instead of the ones installed in node_modules (e.g., --from="@nx/[email protected],@nx/[email protected]").
                                                                                                                                                                     [string]
      --to                        Use the provided versions for packages instead of the ones calculated by the migrator (e.g., --to="@nx/[email protected],@nx/[email protected]").
                                                                                                                                                                     [string]
  -C, --createCommits             Automatically create a git commit after each migration runs.                                                     [boolean] [default: false]
      --commitPrefix              Commit prefix to apply to the commit for each migration, when --create-commits is enabled.     [string] [default: "chore: [nx migration] "]
      --interactive               Enable prompts to confirm whether to collect optional package updates and migrations.                            [boolean] [default: false]
      --excludeAppliedMigrations  Exclude migrations that should have been applied on previous updates. To be used with --from.                    [boolean] [default: false]

Examples:
  migrate latest                                                           Update all Nx plugins to "latest". This will generate migrations.json
  migrate 9.0.0                                                            Update all Nx plugins to "9.0.0". This will generate migrations.json
  migrate @nx/[email protected] --from="@nx/[email protected],@nx/[email protected]"  Update @nx/workspace and generate the list of migrations starting with version 8.0.0 of
                                                                           @nx/workspace and @nx/node, regardless of what is installed locally
  migrate @nx/[email protected] --to="@nx/[email protected],@nx/[email protected]"     Update @nx/workspace to "9.0.0". If it tries to update @nx/react or @nx/angular, use version
                                                                           "9.0.1"
  migrate [email protected]                                           Update another-package to "12.0.0". This will update other packages and will generate
                                                                           migrations.json file
  migrate latest --interactive                                             Collect package updates and migrations in interactive mode. In this mode, the user will be
                                                                           prompted whether to apply any optional package update and migration
  migrate latest [email protected] --exclude-applied-migrations             Collect package updates and migrations starting with version 14.5.0 of "nx" (and Nx first-party
                                                                           plugins), regardless of what is installed locally, while excluding migrations that should have
                                                                           been applied on previous updates
  migrate --run-migrations=migrations.json                                 Run migrations from the provided migrations.json file. You can modify migrations.json and run this
                                                                           command many times
  migrate --run-migrations --create-commits                                Create a dedicated commit for each successfully completed migration. You can customize the prefix
                                                                           used for each commit by additionally setting --commit-prefix="PREFIX_HERE "

Find more information and examples at https://nx.dev/nx/migrate

Error: Command failed: /var/folders/9s/1tc5gj9s3g519shqqfqqq1sc0000gn/T/tmp-97090-L7wjXBToP375/node_modules/.bin/nx _migrate --run-migrations
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:888:11)
    at execSync (node:child_process:960:15)
    at Object.runMigration (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/command-line/migrate/migrate.js:1138:42)
    at Object.handler (/Users/pedroyan/Project/Fintropya/fintropya/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_b7eeda6a44876eab4dc1516db12264e8/node_modules/nx/src/command-line/migrate/command-object.js:13:68) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 97154,
  stdout: null,
  stderr: null
}

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions