Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nx migrate latest - Cannot read properties of undefined (reading 'schematics') #28976

Open
1 of 4 tasks
coreConvention opened this issue Nov 17, 2024 · 1 comment
Open
1 of 4 tasks

Comments

@coreConvention
Copy link

coreConvention commented Nov 17, 2024

Current Behavior

Attempting to upgrade an angular 16 project to 18, however I assume I need to upgrade nx as well. I am currently using 16.3.2, but I have installed nx 20.1.2 globally. Running the nx migrate latest command on the project results in the following error:

NX   The migrate command failed.
NX   Cannot read properties of undefined (reading 'schematics')

TypeError: Cannot read properties of undefined (reading 'schematics')
   at C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:561:24
   at async Migrator.populatePackageJsonUpdatesAndGetPackagesToCheck (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:148:31)
   at async Promise.all (index 2)
   at async Migrator.populatePackageJsonUpdatesAndGetPackagesToCheck (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:178:17)
   at async Migrator.buildPackageJsonUpdates (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:118:33)       
   at async Migrator.migrate (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:84:9)
   at async generateMigrationsJsonAndUpdatePackageJson (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:769:78)
   at async C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\migrate.js:1048:13
   at async handleErrors (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\utils\handle-errors.js:8:24)
   at async Object.handler (C:\Users\[removed]\AppData\Local\Temp\tmp-86904-gDlI6u6BSBlc\node_modules\nx\src\command-line\migrate\command-object.js:21:43)

I see some other issues recommending renaming "@nx/linter" to "@nx/eslint" as that is documented. But I was under the impression the nx migrate command would handle that? Also I am not sure about where that is supposed to be renamed if that is the solution. In the project.json file? Not really sure what to do about this. A quick search of this issue returns only one result pointing to here, which is not helpful.

Expected Behavior

I expect the nx migrate command to properly generate the migrations.json file...? Not sure what else to say here.

GitHub Repo

No response

Steps to Reproduce

  1. run nx migrate latest --verbose

Nx Report

>  Node   : 22.5.1
   OS     : win32 x64
   npm    : 10.8.2
   Hasher : Native

   nx (global)        : 20.1.2
   nx                 : 16.3.2
   @nx/js             : 16.3.2
   @nx/jest           : 16.3.2
   @nx/linter         : 16.3.2
   @nx/workspace      : 16.3.2
   @nx/angular        : 16.3.2
   @nx/cypress        : 16.3.2
   @nx/devkit         : 16.3.2
   @nx/eslint-plugin  : 16.3.2
   @nrwl/tao          : 16.3.2
   @nx/web            : 16.3.2
   @nx/webpack        : 16.3.2
   typescript         : 5.0.4
   ---------------------------------------
   Community plugins:
   @auth0/auth0-angular : 2.2.3

Failure Logs

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\npmrc
4 silly config load:file:C:\Users\[removed]\AppData\Local\Temp\tmp-86668-p4IbSbzgo6tu\.npmrc
5 silly config load:file:C:\Users\[removed]\.npmrc
6 silly config load:file:C:\Program Files\nodejs\etc\npmrc
7 verbose title npm install @nx/[email protected]
8 verbose argv "install" "@nx/[email protected]"
9 verbose logfile logs-max:10 dir:C:\Users\[removed]\AppData\Local\npm-cache\_logs\2024-11-17T16_37_32_787Z-
10 verbose logfile C:\Users\[removed]\AppData\Local\npm-cache\_logs\2024-11-17T16_37_32_787Z-debug-0.log
11 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
12 silly logfile start cleaning logs, removing 2 files
13 silly logfile done cleaning log files
14 silly idealTree buildDeps
15 silly fetch manifest @nx/[email protected]
16 silly packumentCache full:https://registry.npmjs.org/@nx%2flinter cache-miss
17 http fetch GET 200 https://registry.npmjs.org/@nx%2flinter 14ms (cache hit)
18 silly packumentCache full:https://registry.npmjs.org/@nx%2flinter set size:1398210 disposed:false
19 silly placeDep ROOT @nx/linter@ OK for:  want: 20.1.2
20 verbose type version
21 verbose stack @nx/linter: No matching version found for @nx/[email protected].
21 verbose stack     at module.exports (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\npm-pick-manifest\lib\index.js:215:23)
21 verbose stack     at RegistryFetcher.manifest (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\pacote\lib\registry.js:130:54)
21 verbose stack     at async #fetchManifest (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1199:20)
21 verbose stack     at async #nodeFromEdge (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1037:19)
21 verbose stack     at async #buildDepStep (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:901:11)
21 verbose stack     at async Arborist.buildIdealTree (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:181:7)
21 verbose stack     at async Promise.all (index 1)
21 verbose stack     at async Arborist.reify (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
21 verbose stack     at async Install.exec (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\lib\commands\install.js:150:5)
21 verbose stack     at async Npm.exec (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\lib\npm.js:207:9)
21 verbose stack     at async module.exports (C:\Users\[removed]\AppData\Roaming\nvm\v22.5.1\node_modules\npm\lib\cli\entry.js:74:5)
22 error code ETARGET
23 error notarget No matching version found for @nx/[email protected].
24 error notarget In most cases you or one of your dependencies are requesting
24 error notarget a package version that doesn't exist.
25 silly unfinished npm timer reify 1731861453590
26 silly unfinished npm timer reify:loadTrees 1731861453594
27 verbose cwd C:\Users\[removed]\AppData\Local\Temp\tmp-86668-p4IbSbzgo6tu
28 verbose os Windows_NT 10.0.22631
29 verbose node v22.5.1
30 verbose npm  v10.8.2
31 verbose exit 1
32 verbose code 1
33 error A complete log of this run can be found in: C:\Users\[removed]\AppData\Local\npm-cache\_logs\2024-11-17T16_37_32_787Z-debug-0.log

Package Manager Version

10.8.2

Operating System

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

Additional Information

No response

@sebastiandenis
Copy link

I had the same issue with the Nx workspace migration from 16 to 20. A quick workaround is:

  1. remove @nx/linter from your package.json and run npm install
  2. npm install @nx/eslint --save-dev
  3. nx migrate latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants