Repository: nrwl/nx-console

Issue #1810: Process started from NX Console detecting wrong platform
Created: 2023-07-07T02:39:21Z
Current Behavior
Since today, clicking the "play" icon button in the NX Console next to project target using Vite shows this error:

Open to see error
Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.
Specifically the "@esbuild/darwin-arm64" package is present but this platform
needs the "@esbuild/darwin-x64" package instead. People often get into this
situation by installing esbuild with npm running inside of Rosetta 2 and then
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
If you are installing with npm, you can try ensuring that both npm and node are
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
changing how you installed npm and/or node. For example, installing node with
the universal installer here should work: https://nodejs.org/en/download/. Or
you could consider using yarn instead of npm which has built-in support for
installing a package on multiple platforms simultaneously.
If you are installing with yarn, you can try listing both "arm64" and "x64"
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.
Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
    at generateBinPath (/Users/me/galaxy/node_modules/.pnpm/esbuild@0.17.5/node_modules/esbuild/lib/main.js:1873:17)
    at esbuildCommandAndArgs (/Users/me/galaxy/node_modules/.pnpm/esbuild@0.17.5/node_modules/esbuild/lib/main.js:1954:33)
    at ensureServiceIsRunning (/Users/me/galaxy/node_modules/.pnpm/esbuild@0.17.5/node_modules/esbuild/lib/main.js:2118:25)
    at build (/Users/me/galaxy/node_modules/.pnpm/esbuild@0.17.5/node_modules/esbuild/lib/main.js:2010:26)
    at bundleConfigFile (file:///Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:64323:26)
    at loadConfigFromFile (file:///Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:64299:31)
    at resolveConfig (file:///Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:63908:34)
    at _createServer (file:///Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:63192:26)
    at Module.createServer (file:///Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:63189:12)
    at /Users/me/galaxy/node_modules/.pnpm/vite@4.3.4_@types+node@18.14.2_less@4.1.3_sass@1.62.1_stylus@0.55.0/node_modules/vite/index.cjs:23:55

Please note that VS Code updated today which was prior to me noticing this issue, so maybe this is contributing somehow.
Also note that running the equivalent NX target via the command line (be it from VS Code or iTerm) works flawlessly, so it seems to be related to the process that NX Console spins up.
While attempting to address the above esbuild error—which I had seen before and is usually fixed by reinstalling node_modules, but not this time—I ensured that everything about my platform was not installed via Rosetta 2, as I have an M2 chip.
After reinstalling nvm, node, pnpm, VS Code and NX Console, and ensuring they are on arm64, I reran pnpm i on my workspace and got the same error. Then, I ran nx migrate latest, after which the error has changed to this:
 >  NX   Missing Platform Dependency

   The Nx CLI could not find or load the native binary for your supported platform (darwin-x64).
   This likely means that optional dependencies were not installed correctly, or your system is missing some system dependencies.
   For more information please see https://nx.dev/recipes/ci/troubleshoot-nx-install-issues

I did follow the troubleshooting tips in that link and ensured I could find @nx/nx-darwin-arm64 in my node_modules, but this did not fix the issue.

Expected Behavior
Clicking the "play" icon button in the NX Console next to project targets should work like it did yesterday. Ie. it should spin up a process and run the equivalent command.
Steps to Reproduce

Match my environment.
Use a generator to create a React application that uses Vite.
Attempt to use NX Console to run its serve target.
See "Missing Platform Dependency" error.

I was easily able to reproduce the issue by cloning https://github.com/nrwl/nx-examples and attempting to run the apps/cart:serve target via the NX Console. The same error occurred with Yarn, which it is set up to run by default, and also after I changed it to use pnpm.
 *  Executing task: pnpm exec nx run cart:serve 
 
 >  NX   Missing Platform Dependency

   The Nx CLI could not find or load the native binary for your supported platform (darwin-x64).
   This likely means that optional dependencies were not installed correctly, or your system is missing some system dependencies.
   For more information please see https://nx.dev/recipes/ci/troubleshoot-nx-install-issues

 *  The terminal process "/bin/zsh '-l', '-c', 'pnpm exec nx run cart:serve'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 





Environment

Platform:


Chip Apple M2 Pro
MacOS 13.2.1 (22D68)


Nx Console version:


v18.4.0


VSCode version (I tried others also, such as the Apple Silicon version and Insiders, with the same result):


Version: 1.80.0 (Universal)
Commit: 660393deaaa6d1996740ff4880f1bad43768c814
Date: 2023-07-04T13:39:33.766Z
Electron: 22.3.14
ElectronBuildId: 21893604
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.3.0


NX Report:


Node   : 18.15.0
OS     : darwin-arm64
pnpm   : 8.6.6
nx (global)        : 16.3.2
nx                 : 16.5.0
@nx/js             : 16.5.0
@nx/jest           : 16.5.0
@nx/linter         : 16.5.0
@nx/workspace      : 16.5.0
@nx/cypress        : 16.5.0
@nx/devkit         : 16.5.0
@nx/esbuild        : 16.5.0
@nx/eslint-plugin  : 16.5.0
@nx/plugin         : 16.5.0
@nx/react          : 16.5.0
@nx/vite           : 16.5.0
@nx/webpack        : 16.5.0
nx-cloud           : 16.0.5
typescript         : 5.1.6

Duplicate issue #1820: NX  Missing Platform Dependency (darwin-x64) when executing build, serve or test on new workspace
Created: 2023-07-12T13:57:07Z
Current Behavior
Using Nx Console to build, serve or test an Angular application created in a new 16.5.0 Nx Workspace results in the following error:

Executing task: npx nx run my-app:test
NX   Missing Platform Dependency
The Nx CLI could not find or load the native binary for your supported platform (darwin-x64).

However if I copy the generated cli command into my terminal, it runs fine there.
Expected Behavior
Nx Console should be able to run the command like the Terminal cli command can
Steps to Reproduce

npm create nx-workspace
Which stack do you want to use? choose Angular
Standalone project or integrated monorepo? choose Integrated Monorepo
Default stylesheet format - choose SASS
rest of options - choose defaults
Open new workspace in VSCode
Try build, serve or test from Nx Console

Environment
OS: macOS Ventura 13.4.1

Nx Console version: v18.5.0
VSCode version: 1.80.0 (Universal)

Closing comment (2023-07-12T14:06:13Z): closing as a duplicate of #1810