nx: nx 13 migration fails - Cannot find module '@angular-devkit/core'

Current Behavior

While running migrations from nx 12 to nx 13.2.0, a number of migrations fail, complaining that @anguar-devkit/core is not found. I have tried to install this package both in the workspace, but also globally without any success. (v 13.0.3)

Expected Behavior

I expect the migrations to run successfully I have not seen this behaviour earlier.

Steps to Reproduce

I am not in a position to share the code.

Failure Logs

Running migration set-default-base-if-not-set Successfully finished set-default-base-if-not-set

Running migration 13-0-0-config-locations Successfully finished 13-0-0-config-locations

Running migration set-parallel-default Successfully finished set-parallel-default

Running migration add-postcss-packages Successfully finished add-postcss-packages

Running migration update-angular-config Successfully finished update-angular-config

Running migration update-libraries Successfully finished update-libraries

Running migration update-angular-jest-config Successfully finished update-angular-jest-config

Running migration update-testing-imports Successfully finished update-testing-imports

Running migration schematic-options-13 Cannot find module ‘@angular-devkit/core’ Require stack:

  • C:\Users.…\AppData\Local\Temp\tmp-19508-D60cNX54O84e\node_modules@nrwl\tao\src\commands\ngcli-adapter.js
  • C:\Users.…\AppData\Local\Temp\tmp-19508-D60cNX54O84e\node_modules@nrwl\tao\src\commands\migrate.js
  • C:\Users.…\AppData\Local\Temp\tmp-19508-D60cNX54O84e\node_modules@nrwl\tao\index.js C:\dev\node_modules\yargs\build\lib\yargs.js:1132 throw err; ^

Error: Command failed: C:\Users.…\AppData\Local\Temp\tmp-19508-D60cNX54O84e\node_modules.bin\tao migrate --run-migrations at checkExecSyncError (child_process.js:760:11) at execSync (child_process.js:833:15) at Object.handler (C:\dev\ForumWebKlient-3\node_modules@nrwl\workspace\src\command-line\nx-commands.js:125:42) at Object.runCommand (C:\dev\ForumWebKlient-3\node_modules\yargs\build\lib\command.js:196:48) at Object.parseArgs [as _parseArgs] (C:\dev\ForumWebKlient-3\node_modules\yargs\build\lib\yargs.js:1043:55) at Object.get [as argv] (C:\dev\ForumWebKlient-3\node_modules\yargs\build\lib\yargs.js:986:25) at initLocal (C:\dev\ForumWebKlient-3\node_modules@nrwl\cli\lib\init-local.js:28:79) at Object.<anonymous> (C:\dev\ForumWebKlient-3\node_modules@nrwl\cli\bin\nx.js:43:32) at Module._compile (C:\Users\jorn.are.hatlelid\AppData\Roaming\npm\node_modules\nx\node_modules\v8-compile-cache\v8-compile-cache.js:192:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:1101:10) { status: 1, signal: null, output: [ null, null, null ], pid: 13104, stdout: null, stderr: null }

Environment

Node : 14.17.4 OS : win32 x64 npm : 6.14.14

nx : 13.2.0 @nrwl/angular : 13.2.0 @nrwl/cli : 13.2.0 @nrwl/cypress : 13.2.0 @nrwl/devkit : 12.10.0 @nrwl/eslint-plugin-nx : 13.2.0 @nrwl/express : undefined @nrwl/jest : 13.2.0 @nrwl/linter : 13.2.0 @nrwl/nest : undefined @nrwl/next : undefined @nrwl/node : undefined @nrwl/nx-cloud : undefined @nrwl/react : undefined @nrwl/react-native : undefined @nrwl/schematics : undefined @nrwl/tao : 13.2.0 @nrwl/web : undefined @nrwl/workspace : 13.2.0 @nrwl/storybook : 12.10.0 @nrwl/gatsby : undefined typescript : 4.4.4 rxjs : 6.6.7

Community plugins: @angular/animations: 13.0.0 @angular/cdk: 13.0.0 @angular/common: 13.0.0 @angular/compiler: 13.0.0 @angular/core: 13.0.0 @angular/forms: 13.0.0 @angular/platform-browser: 13.0.0 @angular/platform-browser-dynamic: 13.0.0 @angular/router: 13.0.0 @datorama/akita: 6.2.4 @fortawesome/angular-fontawesome: 0.9.0 @nebular/theme: 8.0.0 @angular-devkit/build-angular: 13.0.3 @angular/cli: 13.0.3 @angular/compiler-cli: 13.0.0 @angular/language-service: 13.0.0 @storybook/angular: 6.3.12

About this issue

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

Most upvoted comments

Thanks for reporting this!

I’ve pushed a fix for it and we’ll cut a patch release with it soon.

If you want to unblock yourself before the fix goes out, you can do the following:

# using npm and cmd

npm install -D @nrwl/tao@latest

SET NX_MIGRATE_USE_LOCAL=true&& nx migrate latest

SET NX_MIGRATE_USE_LOCAL=true&& nx migrate --run-migrations

I’ve seen some comments in this thread saying to add "cli": "nx" to migrations missing it, please don’t do that, it’s not correct. That’s a property that identifies migrations created with the Nx DevKit. Migrations from third-party packages might have been created with the Angular DevKit and therefore are not meant to have the "cli": "nx". Normally, all migrations from @nrwl/* packages will have that, and migrations from @angular/* won’t and that’s correct.

(Windows 11) I took the advice above to add "cli": "nx" to migrations and the devkit/core error is gone but now it’s failing on

Running migration set-parallel-default
Successfully finished set-parallel-default
---------------------------------------------------------
Running migration update-angular-config
Successfully finished update-angular-config
---------------------------------------------------------
Running migration update-libraries
Successfully finished update-libraries
---------------------------------------------------------
Running migration update-angular-jest-config
Successfully finished update-angular-jest-config
---------------------------------------------------------
Running migration update-testing-imports
Successfully finished update-testing-imports
---------------------------------------------------------
Running migration schematic-options-13
Successfully finished schematic-options-13
---------------------------------------------------------
Running migration update-angular-config-v13
Successfully finished update-angular-config-v13
---------------------------------------------------------
Running migration update-libraries-v13
Successfully finished update-libraries-v13
---------------------------------------------------------
Running migration drop-ie-polyfills
Successfully finished drop-ie-polyfills
---------------------------------------------------------
Running migration update-gitignore
Successfully finished update-gitignore
---------------------------------------------------------
Running migration migration-v13-router-link-empty-expression
Successfully finished migration-v13-router-link-empty-expression
---------------------------------------------------------
Running migration migration-v13-testbed-teardown
Successfully finished migration-v13-testbed-teardown
---------------------------------------------------------
Running migration migration-v13
Cannot find module 'C:\development\SDS\core-ui-v3\node_modules\@angular\material\schematics/./ng-update/index#updateToV13'

although the updateToV13 exists… image

This does seem to be a Windows issue. I have the same issue running the migrations on Windows. As @cmcgroarty pointed out this does work on Linux. I ran the migrations in WSL with Ubuntu without any issues.

@FrozenPandaz Encountered the issue with a fresh workspace and angular project on Windows 10. https://github.com/cmcgroarty/nx-12-to-13

Rerunning nx migrate --run-migrations on the repo after install encounters the error on Windows, but works fine on Linux (CentOS 7)

npx create-nx-workspace@12.0.0
nx migrate 13.2.0
npm install
nx migrate --run-migrations
>  NX  Running migrations from 'migrations.json'

Running migration add-target-dependencies

>  NX   NOTE  Target dependencies have been updated in nx.json

  Nx has deprecated strictlyOrderedTargets in favour of targetDependencies.
  Based on your configuration the migration has configured targetDependencies for the following targets: build.
  Read more here: https://nx.dev/core-concepts/configuration

Successfully finished add-target-dependencies
---------------------------------------------------------
Running migration set-default-base-if-not-set
Successfully finished set-default-base-if-not-set
---------------------------------------------------------
Running migration 13-0-0-config-locations
Successfully finished 13-0-0-config-locations
---------------------------------------------------------
Running migration set-parallel-default
Successfully finished set-parallel-default
---------------------------------------------------------
Running migration update-webpack-browser-config
Successfully finished update-webpack-browser-config
---------------------------------------------------------
Running migration update-storybook
Successfully finished update-storybook
---------------------------------------------------------
Running migration update-angular-eslint-rules
Successfully finished update-angular-eslint-rules
---------------------------------------------------------
Running migration convert-webpack-browser-build-target-to-delegate-build
Successfully finished convert-webpack-browser-build-target-to-delegate-build
---------------------------------------------------------
Running migration update-invalid-import-paths
Successfully finished update-invalid-import-paths
---------------------------------------------------------
Running migration add-postcss-packages
Successfully finished add-postcss-packages
---------------------------------------------------------
Running migration update-angular-config
Successfully finished update-angular-config
---------------------------------------------------------
Running migration update-libraries
Successfully finished update-libraries
---------------------------------------------------------
Running migration update-angular-jest-config
Successfully finished update-angular-jest-config
---------------------------------------------------------
Running migration update-testing-imports
Successfully finished update-testing-imports
---------------------------------------------------------
Running migration schematic-options-13
Cannot find module '@angular-devkit/core'
Require stack:
- ~\AppData\Local\Temp\tmp-24140-14Bhrtd0OOQg\node_modules\@nrwl\tao\src\commands\ngcli-adapter.js
- ~\AppData\Local\Temp\tmp-24140-14Bhrtd0OOQg\node_modules\@nrwl\tao\src\commands\migrate.js
- ~\AppData\Local\Temp\tmp-24140-14Bhrtd0OOQg\node_modules\@nrwl\tao\index.js
~\nx12to13\node_modules\yargs\build\lib\yargs.js:1132
                throw err;
                ^

Error: Command failed: ~\AppData\Local\Temp\tmp-24140-14Bhrtd0OOQg\node_modules\.bin\tao migrate --run-migrations
    at checkExecSyncError (child_process.js:790:11)
    at execSync (child_process.js:863:15)
    at Object.handler (~\nx12to13\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:125:42)
    at Object.runCommand (~\nx12to13\node_modules\yargs\build\lib\command.js:196:48)
    at Object.parseArgs [as _parseArgs] (~\nx12to13\node_modules\yargs\build\lib\yargs.js:1043:55)
    at Object.get [as argv] (~\nx12to13\node_modules\yargs\build\lib\yargs.js:986:25)
    at initLocal (~\nx12to13\node_modules\@nrwl\cli\lib\init-local.js:28:79)
    at Object.<anonymous> (~\nx12to13\node_modules\@nrwl\cli\bin\nx.js:43:32)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 10076,
  stdout: null,
  stderr: null
}

Maybe this will help because I had the exact same problem, but after deleting node_modules and running yarn/npm install again, it worked.

It seems that the reason for this issue is an outdated version of nx. I had it installed locally globally and the migration process didn’t update it automatically ofc, so a simple update resolved this issue.

@FrozenPandaz I’m able to reproduce this in my repo: https://github.com/ideacrew/active-branch-tracker

after running a fresh npm install, then npx nx migrate latest and npx nx migrate --run-migration I get the exact same error as the above comments show

EDIT: Running Windows 11 (thanks @andrewalderson)

2nd EDIT: Confirmed that running this same exact process on the above repo on a Mac (12.0.1) works perfectly. No error messaging.

Seems like many of the migrations are missing the “cli” attribute. Adding “cli”: “nx” made the migrations run succesfully. (except the cdk upgrade)