nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.02k stars 2.3k forks source link

NX console client not running: Error: Cannot find module '@nx/nx-darwin-arm64' #20617

Closed fitimsijarinaa closed 7 months ago

fitimsijarinaa commented 8 months ago

Current Behavior

The NX console client is not running.

Expected Behavior

Should run without any issues.

GitHub Repo

No response

Steps to Reproduce

1.

Nx Report

Node   : 21.4.0
   OS     : darwin-x64
   npm    : 10.2.4

   nx (global)        : 17.1.3
   nx                 : 17.1.2
   @nx/js             : 17.1.2
   @nx/jest           : 17.1.2
   @nx/linter         : 17.1.2
   @nx/eslint         : 17.1.2
   @nx/workspace      : 17.1.2
   @nx/angular        : 17.1.2
   @nx/cypress        : 17.1.2
   @nx/devkit         : 17.1.2
   @nx/esbuild        : 17.1.2
   @nx/eslint-plugin  : 17.1.2
   @nx/nest           : 17.1.2
   @nx/node           : 17.1.2
   @nrwl/tao          : 17.1.2
   @nx/web            : 17.1.2
   @nx/webpack        : 17.0.3
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @ngneat/hot-toast    : 6.0.1
   @ngneat/transloco    : 6.0.0
   @ngrx/operators      : 17.0.1
   @ngrx/signals        : 17.0.1
   @rx-angular/template : 16.1.1
   ng2-charts           : 5.0.3
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nx/webpack@17.0.3
     - @nrwl/webpack@17.0.3

Failure Logs

[Nxls] - 2023-12-06T20:47:11.898Z - Retrieving workspace configuration

[Nxls] - 2023-12-06T20:47:11.946Z - Using local Nx package at /Users/USER/node_modules/nx/src/project-graph/file-utils.js

[Nxls] - 2023-12-06T20:47:11.946Z - Using local Nx package at /Users/USER/node_modules/nx/src/project-graph/file-map-utils.js

[Nxls] - 2023-12-06T20:47:11.946Z - Using local Nx package at /Users/USER/node_modules/nx/src/utils/output.js

[Nxls] - 2023-12-06T20:47:11.946Z - Using local Nx package at /Users/USER/node_modules/nx/src/project-graph/project-graph.js

[Nxls] - 2023-12-06T20:47:11.962Z - createProjectGraphAsync

[Nxls] - 2023-12-06T20:47:11.976Z - Unable to get project graph

[Nxls] - 2023-12-06T20:47:11.976Z - Error: Cannot find module '@nx/nx-darwin-arm64'
Require stack:
- /Users/USER/node_modules/nx/src/native/index.js
- /Users/USER/node_modules/nx/src/utils/workspace-context.js
- /Users/USER/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js
- /Users/USER/node_modules/nx/src/config/workspaces.js
- /Users/USER/node_modules/nx/src/utils/nx-plugin.js
- /Users/USER/node_modules/nx/src/project-graph/build-project-graph.js
- /Users/USER/node_modules/nx/src/project-graph/project-graph.js
- /Users/USER/node_modules/nx/src/project-graph/file-utils.js
- /Users/user/.vscode/extensions/nrwl.angular-console-18.10.1/nxls/main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1129:15)
    at Module._load (node:internal/modules/cjs/loader:974:27)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Module.require (node:internal/modules/cjs/loader:1195:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/USER/node_modules/nx/src/native/index.js:135:29)
    at Module._compile (node:internal/modules/cjs/loader:1316:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1371:10)
    at Module.load (node:internal/modules/cjs/loader:1171:32)
    at Module._load (node:internal/modules/cjs/loader:1012:12)

[Nxls] - 2023-12-06T20:47:11.977Z - Retrieved workspace configuration in: 78.66687499731779 ms

Package Manager Version

No response

Operating System

Additional Information

No response

csutorasr commented 8 months ago

This is probably related: https://github.com/nrwl/nx/issues/19604

These were optional dependencies and later removed. I fixed this by removing the package-lock and node_modules and run npm install.

fitimsijarinaa commented 8 months ago

Actually this didn't help. Tried it many times. I don't have this problem with a project with nx v16.8.1. There the NX console client is working well.

fitimsijarinaa commented 8 months ago

I set up a completely new monorepo from the tutorial https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial. Still the same issue. Any ideas?

fitimsijarinaa commented 8 months ago

The nx daemon is also disabled.

/Users/.../angular-monorepo/node_modules/nx/src/native/index.js:244
    throw loadError
    ^

Error: Cannot find module '@nx/nx-darwin-arm64'
Require stack:
- /Users/.../angular-monorepo/node_modules/nx/src/native/index.js
- /Users/.../angular-monorepo/node_modules/nx/src/daemon/server/server.js
- /Users/.../angular-monorepo/node_modules/nx/src/daemon/server/start.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1129:15)
    at Module._load (node:internal/modules/cjs/loader:974:27)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Module.require (node:internal/modules/cjs/loader:1195:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/.../angular-monorepo/node_modules/nx/src/native/index.js:135:29)
    at Module._compile (node:internal/modules/cjs/loader:1316:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1371:10)
    at Module.load (node:internal/modules/cjs/loader:1171:32)
    at Module._load (node:internal/modules/cjs/loader:1012:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/.../angular-monorepo/node_modules/nx/src/native/index.js',
    '/Users/.../angular-monorepo/node_modules/nx/src/daemon/server/server.js',
    '/Users/.../angular-monorepo/node_modules/nx/src/daemon/server/start.js'
  ]
}

Node.js v18.15.0

I am not sure why Node.js v18.15.0 is being shown. With nvm I am using now v20.10.0.

csutorasr commented 7 months ago

As the error is thrown at /Users/USER/node_modules/nx/... I assume that this is a globally installed version of nx. Try to run npx nx ... if you are using npm. If that works, then update the global version of nx and check you $PATH. Something might be messed up with your node versions. On MacOS it is worthy to use nvm.

fitimsijarinaa commented 7 months ago

@csutorasr thanks for ur response. I am using nvm and the problem is happening just with Node version 20. If I type in the terminal node -p 'process.arch' for all other versions the output is arm64. Just for node version 20 the output is x64.

If anyone know how to change that, then for this node version it is solved as well. Because I can not run the nx console client. This is the vs code extension I am talking about here.

csutorasr commented 7 months ago

However this has nothing to do with the nx itself. Please consider using an .nvmrc or set the default nvm version to a working version.

I would close this ticket.

kerryj89 commented 7 months ago

This is probably not the same as your case, but posting it here. I guess I had dragged node_modules into my home directory at one point. Anyway, my dev folder is also inside my home directory. NPM tries to resolve packages by traversing up directories and it got stuck in my home directory. In my mind it would continue to the globally installed packages but I guess not in this case?

github-actions[bot] commented 6 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.