Skip to content

Nx migrate error moving from nx@21.1.0 to nx@latest: Cannot find module '@angular/core' #32734

@rpd10

Description

@rpd10

Current Behavior

Attempting a Nx migration from version 21.1.3 to 21.2.0 yields errors on any migration from @angular/core. I found #31838 and attempted the workarounds there, to no avail. I've tried both the Nx Console migrate UI, and the CLI. I've been able to narrow it down to the update from 21.1 => 21.2. The logs below

  • When running via the CLI, the migration appears to hang on the inject-flags migration
  • When running via the migrate UI, I get the following error for any Angular related migration, starting with inject-flags:
Cannot find module '@angular/core'
Require stack:
- /Users/rydiehl/Projects/cx-platform-ui/node_modules/nx/src/utils/package-json.js
- /Users/rydiehl/Projects/cx-platform-ui/node_modules/nx/src/utils/package-manager.js
- /Users/rydiehl/.vscode/extensions/nrwl.angular-console-18.67.0/main.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js

If I skip the migration, it happens for any other Angular-related migration.

Expected Behavior

Migration works without errors and applies all relevant Angular migrations without forcing me to skip them

GitHub Repo

No response

Steps to Reproduce

  1. npx nx migrate latest or npx nx migrate 21.2

Nx Report

/** Before starting migration */
Node           : 22.19.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.3

nx                     : 21.1.3
@nx/js                 : 21.1.3
@nx/jest               : 21.1.3
@nx/eslint             : 21.1.3
@nx/workspace          : 21.1.3
@nx/angular            : 21.1.3
@nx/cypress            : 21.1.3
@nx/devkit             : 21.1.3
@nx/eslint-plugin      : 21.1.3
@nx/express            : 21.1.3
@nx/module-federation  : 21.1.3
@nx/node               : 21.1.3
@nx/playwright         : 21.1.3
@nx/plugin             : 21.1.3
@nx/rspack             : 21.1.3
@nx/storybook          : 21.1.3
@nx/vite               : 21.1.3
@nx/web                : 21.1.3
@nx/webpack            : 21.1.3
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin
@nx/playwright/plugin
@nx/webpack/plugin
---------------------------------------
Community plugins:
@compodoc/compodoc       : 1.1.26
@jsverse/transloco       : 7.5.1
@ngrx/component-store    : 19.0.1
@ngrx/entity             : 19.1.0
@ngrx/operators          : 19.0.1
@ngrx/signals            : 19.0.1
@ngrx/store              : 19.0.1
@storybook/angular       : 8.6.12
@testing-library/angular : 17.3.5
angular-eslint           : 19.2.0
apollo-angular           : 10.0.3
---------------------------------------
Local workspace plugins:
         @polarity/components
         workspace-plugin
---------------------------------------
Cache Usage: 0.00 B / 46.04 GB


/** During migration at the point the error happens (when migrating to latest) */
Node           : 22.19.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.3

nx                     : 21.5.2
@nx/js                 : 21.5.2
@nx/jest               : 21.5.2
@nx/eslint             : 21.5.2
@nx/workspace          : 21.5.2
@nx/angular            : 21.5.2
@nx/cypress            : 21.5.2
@nx/devkit             : 21.5.2
@nx/eslint-plugin      : 21.5.2
@nx/express            : 21.5.2
@nx/module-federation  : 21.5.2
@nx/node               : 21.5.2
@nx/playwright         : 21.5.2
@nx/plugin             : 21.5.2
@nx/rspack             : 21.5.2
@nx/storybook          : 21.5.2
@nx/vite               : 21.5.2
@nx/web                : 21.5.2
@nx/webpack            : 21.5.2
@nx/docker             : 21.5.2
typescript             : 5.9.2
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin
@nx/playwright/plugin
@nx/webpack/plugin
---------------------------------------
Community plugins:
@compodoc/compodoc       : 1.1.26
@jsverse/transloco       : 7.5.1
@ngrx/component-store    : 20.0.1
@ngrx/entity             : 20.0.1
@ngrx/operators          : 20.0.1
@ngrx/signals            : 20.0.1
@ngrx/store              : 20.0.1
@storybook/angular       : 9.1.6
@testing-library/angular : 17.3.5
angular-eslint           : 20.3.0
apollo-angular           : 11.0.0
---------------------------------------
Local workspace plugins:
@polarity/components
workspace-plugin
---------------------------------------
Cache Usage: 0.00 B / 46.04 GB

Failure Logs

Cannot find module '@angular/core'
Require stack:
- /Users/rydiehl/Projects/cx-platform-ui/node_modules/nx/src/utils/package-json.js
- /Users/rydiehl/Projects/cx-platform-ui/node_modules/nx/src/utils/package-manager.js
- /Users/rydiehl/.vscode/extensions/nrwl.angular-console-18.67.0/main.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js



At the time this error occurs, if I run `npm ls @angular/core` I get this:
cx-platform-ui@0.0.0 /Users/rydiehl/Projects/cx-platform-ui
├─┬ @angular-devkit/build-angular@20.2.2
│ ├─┬ @angular/build@20.2.2
│ │ └── @angular/core@20.2.4 deduped
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/animations@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/cdk@20.2.3
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/common@20.2.4
│ └── @angular/core@20.2.4 deduped
├── @angular/core@20.2.4 overridden
├─┬ @angular/forms@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/platform-browser-dynamic@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/platform-browser@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/platform-server@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/router@20.2.4
│ └── @angular/core@20.2.4 deduped
├─┬ @angular/ssr@20.2.2
│ └── @angular/core@20.2.4 deduped
├─┬ @jsverse/transloco-locale@7.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @jsverse/transloco-messageformat@7.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @jsverse/transloco@7.5.1
│ └── @angular/core@20.2.4 deduped
├─┬ @ngrx/component-store@20.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @ngrx/entity@20.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @ngrx/signals@20.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @ngrx/store@20.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ @okta/okta-angular@6.4.0
│ └── @angular/core@20.2.4 deduped
├─┬ @storybook/angular@9.1.6
│ └── @angular/core@20.2.4 deduped
├─┬ @tanstack/angular-query-experimental@5.69.1
│ └── @angular/core@20.2.4 deduped
├─┬ @testing-library/angular@17.3.5
│ └── @angular/core@20.2.4 deduped
├─┬ ag-grid-angular@33.2.1
│ └── @angular/core@20.2.4 deduped
├─┬ apollo-angular@11.0.0
│ └── @angular/core@20.2.4 deduped
├─┬ highcharts-angular@4.0.1
│ └── @angular/core@20.2.4 deduped
├─┬ jest-preset-angular@15.0.0
│ └── @angular/core@20.2.4 deduped
├─┬ ngx-indexed-db@19.3.1
│ └── @angular/core@20.2.4 deduped
├─┬ ngx-lottie@12.0.0
│ └── @angular/core@20.2.4 deduped
├─┬ ngx-mapbox-gl@13.0.0
│ └── @angular/core@20.2.4 deduped
└─┬ ngx-monaco-editor-v2@19.0.2 overridden
  └── @angular/core@20.2.4 deduped

Package Manager Version

No response

Operating System

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

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions