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)
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:
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 onalthough the
updateToV13exists…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-migrationson the repo after install encounters the error on Windows, but works fine on Linux (CentOS 7)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 latestandnpx nx migrate --run-migrationI get the exact same error as the above comments showEDIT: 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)