nx icon indicating copy to clipboard operation
nx copied to clipboard

The Nx Daemon is unsupported in WebAssembly environments

Open yannick-bonnefond opened this issue 1 year ago • 78 comments

Current Behavior

Starting from this morning any nx commands display the following message on my monorepo, then get stuck for while and fails with the following error

The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected
memory allocation of 1073741824 bytes failed
wasm://wasm/00b1b546:1


RuntimeError: unreachable
    at wasm://wasm/00b1b546:wasm-function[3313]:0x245577
    at wasm://wasm/00b1b546:wasm-function[3235]:0x24532e
    at wasm://wasm/00b1b546:wasm-function[3249]:0x2453a4
    at wasm://wasm/00b1b546:wasm-function[3123]:0x244de2
    at wasm://wasm/00b1b546:wasm-function[3135]:0x244e7f
    at wasm://wasm/00b1b546:wasm-function[3134]:0x244e74
    at wasm://wasm/00b1b546:wasm-function[3131]:0x244e4f
    at wasm://wasm/00b1b546:wasm-function[2919]:0x243a70
    at wasm://wasm/00b1b546:wasm-function[1894]:0x224274
    at wasm://wasm/00b1b546:wasm-function[1221]:0x1f2606

I also try to run npx create-nx-workspace to test a fresh install and got the same result. Node dependencies are properly installed but the subsequent nx commands fails.

The Nx Daemon is unsupported in WebAssembly environments message comes from the daemon client and it seems that IS_WASM here detects a wasm32 arch for some reason

I guess this issue might be specific to my local setup and I am not sure what have changed since I last run an nx commands (maybe a few days ago).

Let me know if I can provide any additional information. Thanks for the help

Expected Behavior

nx commands to run successfully

GitHub Repo

No response

Steps to Reproduce

  1. run npx create-nx-workspace

Nx Report

Running `npx nx report` yield the same issue

Failure Logs

No response

Package Manager Version

npm:10.2.4

Operating System

  • [X] macOS
  • [ ] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

System Version: macOS 14.5 (23F79) Kernel Version: Darwin 23.5.0 Node version 20.11.1

yannick-bonnefond avatar Aug 01 '24 17:08 yannick-bonnefond

Rolling back to version 19.4.4 seems to fix the issue.

thanks @nathanqtlv for spotting it

yannick-bonnefond avatar Aug 02 '24 10:08 yannick-bonnefond

same issue on windows 11

yan-loong avatar Aug 02 '24 13:08 yan-loong

I have the same issue on windows 11 and wsl2 today with 19.5.6. Downgrading to 19.4.4 did not work either. Strange thing is that it was working today, until an hour ago although i did not change anything.

NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  An error occurred while processing files for the @nx/vite/plugin plugin.
    - apps/main/vite.config.ts: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
      Error: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
          at requireWithFriendlyError (Q:\Works\***\******\node_modules\rollup\dist\native.js:59:9)
          at Object.<anonymous> (Q:\Works\***\******\node_modules\rollup\dist\native.js:68:76)
          at Module._compile (node:internal/modules/cjs/loader:1358:14)
          at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
          at Module.load (node:internal/modules/cjs/loader:1208:32)
          at Module._load (node:internal/modules/cjs/loader:1024:12)
          at cjsLoader (node:internal/modules/esm/translators:348:17)
          at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7)
          at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
          at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    - apps/mobile/vite.config.ts: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.

EDIT: Deleting node_modules, package-lock.json and .nx folder, and rerunning npm install solved the issue. No need to downgrade.

ardabeyazoglu avatar Aug 05 '24 20:08 ardabeyazoglu

On my end, since it happens when running npx create-nx-workspace there are no node_modules, package-lock.json or .nx folder to clean up.

Running npm cache clear --force does not resolve the issue either.

yannick-bonnefond avatar Aug 06 '24 06:08 yannick-bonnefond

same issue on macOS 12.7.1 "nx": "19.5.4"

Rolling back to version 19.4.4 seems to fix the issue too

But I'm confused, because I've tested the same project on other setups and didn't get this error (tested on m2, m3 apple chips, macOS 14+)

GlebUrentsev avatar Aug 06 '24 15:08 GlebUrentsev

same issue for our setup. rolling back to v19.5.5 fixed the issue.

thilohaas avatar Aug 07 '24 06:08 thilohaas

Deleting node_modules, package-lock.json and .nx folder, and rerunning npm install

This also worked for me on macOS 14+ without downgrading.

danrex avatar Aug 07 '24 16:08 danrex

Same issue on Fedora 40.

BergLucas avatar Aug 08 '24 09:08 BergLucas

I wonder if this issue could be caused by security software somehow preventing memory allocation by Rust code. (I've noticed that the SWC npm post-install script hangs as well, might be related).

I observed that a security software process on my machine shows CPU activity correlated with running the nx command.

  • Before running the nx command, the security software's CPU usage is around 0.2%.
  • While running the nx command, the security software process spikes to 3% CPU usage, and the nx command's node child process jumps to 99%.
  • Both processes remain at these CPU levels until I kill the node process, after which the security software's CPU usage returns to 0.2%.

I don't have much knowledge about Rust, memory allocation and if a security software can actually cause this, but tight now that's my best bet from what I observe...

@BergLucas, @GlebUrentsev, @thilohaas, Do you have any security software set up on the machine running the nx command? Or have you observed any other processes whose behavior correlates with the execution of the nx command?

cc @FrozenPandaz

yannick-bonnefond avatar Aug 13 '24 06:08 yannick-bonnefond

Hi @yannick-bonnefond,

I forgot to say that, in my case, I fixed the error by setting the version of @swc/core to 1.5.7 instead of ~1.5.7 in my project. I have colleagues who had the same problem on Windows and this solved the problem on their machines too so the problem may be related to @swc/core or some packages that depends on it.

BergLucas avatar Aug 13 '24 14:08 BergLucas

The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected. Cannot find project 'react-store'

Node : 22.4.0 OS : win32-x64 Native Target : wasm32 npm : 10.8.1

nx (global) : 19.6.1 nx : 19.6.1 @nx/js : 19.6.1 @nx/jest : 19.6.1 @nx/linter : 19.6.1 @nx/eslint : 19.6.1 @nx/workspace : 19.6.1 @nx/devkit : 19.6.1 @nx/eslint-plugin : 19.6.1 @nx/next : 19.6.1 @nx/react : 19.6.1 @nrwl/tao : 19.6.1 @nx/web : 19.6.1 @nx/webpack : 19.6.1 typescript : 5.5.4

arehmaanmughal avatar Aug 20 '24 06:08 arehmaanmughal

Possibly related to https://github.com/nrwl/nx/pull/22870?

MilanKovacic avatar Aug 20 '24 15:08 MilanKovacic

I had the same problem with nx version 19.5.2. in my case just reinstalling the node modules (npm ci) did the trick.

Node : 20.15.1 OS : darwin-arm64 npm : 10.7.0 nx : 19.5.2

stefantrost avatar Aug 21 '24 08:08 stefantrost

I transferred a project from my personal laptop to my company laptop. When I try to serve the app on the company laptop, I encounter an error that did not occur on my personal laptop, where there were no daemon issues either. I am using Windows 11 Pro. Could this issue be related to administrator rights or the Nx version 19.6.2?

npm - 10.8.2 node - 20.15.1

shibin-mre avatar Aug 22 '24 12:08 shibin-mre

Just ran into this issue and found that we had optionalDependencies that were installing the binaries manually. When we upgraded we forgot to update the binaries that were optionally installed.

zackarychapple avatar Aug 23 '24 13:08 zackarychapple

Just ran into this issue and found that we had optionalDependencies that were installing the binaries manually. When we upgraded we forgot to update the binaries that were optionally installed.

Did you resolve the issue by manually installing the optional Dependencies ?

shibin-mre avatar Aug 25 '24 23:08 shibin-mre

Did you resolve the issue by manually installing the optional Dependencies ?

Already had them due to CI/CD needs.

zackarychapple avatar Aug 27 '24 00:08 zackarychapple

Personally, this issue is only coming when using the Nx VSC Extension. I am able to manually run npx nx run angular-monorepo:serve w/o issues.

KaliaHayes avatar Aug 27 '24 16:08 KaliaHayes

I fixed this error by install Microsoft Visual C++ 2015 Redistributable (x64) vc_redist.x64.exe OS: windows 11

lihongwang avatar Aug 30 '24 03:08 lihongwang

same problem :(

khoibuda2504 avatar Aug 30 '24 07:08 khoibuda2504

I had this same issue on macOS 14.6.1, node 20.17.0, npm 10.8.2

Downgrading to 19.4.4 fixed the issue for me and so did upgrading to 19.6.4

jonjnicholson avatar Sep 03 '24 13:09 jonjnicholson

NX The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected.

Same issue on Windows pro 23h2 with PNPM 9.9.0 Blocked for 2 days by this problem, I'm happy to run parallel scripts on all the packages that make up monorepo.

ussfranck avatar Sep 05 '24 19:09 ussfranck

Bug Fix: Microsoft Visual C++ Redistributable Update

Issue: After an extended period of troubleshooting, it was identified that the issue was related to an outdated Microsoft Visual C++ Redistributable on Windows systems.

Solution: Ensure that the Microsoft Visual C++ Redistributable is up-to-date. This update resolves compatibility issues and improves overall stability.

Details: Affected Platform: Windows 11 Download link: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

yan-loong avatar Sep 08 '24 06:09 yan-loong

I had same issue on Windows 11, node 20.15.1, npm 10.7.1. Pls help me! image

mdungmc avatar Sep 25 '24 04:09 mdungmc

I had same issue on Windows 11, node 20.15.1, npm 10.7.1. Pls help me! image

Hello, You have this Web Assembly problem because NX needs to rely on certain operating system dependencies to work if you're on Windows, you have to download or update your Microsoft Redistributable C++, on the other hand I'm a Rust developer, so I had to install the C++ environment and thus get all these tools there, the Windows SDK included, when heavy, I don't know if this dependency is mandatory to solve the problem in all it worked on my side.

Concerning the message that web cannot be found in your nx.json, have you checked whether this location is targeted by NX in {projectRoot}/?

Get the latest Microsoft Redistributable C++ on: https://answers.microsoft.com/en-us/windows/forum/all/looking-for-microsoft-visual-c-2022/ac35251f-6ad9-4dd3-939a-c7c70b1f63b8

ussfranck avatar Sep 26 '24 13:09 ussfranck

nx serve

 NX   The Nx Daemon is unsupported in WebAssembly environments.
 Some things may be slower than or not function as expected.

The above is what was giving me issues.

The below worked.

npx nx serve

taranjs avatar Oct 02 '24 14:10 taranjs

nx serve

 NX   The Nx Daemon is unsupported in WebAssembly environments.
 Some things may be slower than or not function as expected.

The above is what was giving me issues.

The below worked.

npx nx serve

If you're running Windows, this problem arises from the absence of certain dependencies in the OS. Please try referring to this comment https://github.com/nrwl/nx/issues/27263#issuecomment-2377053237 to see if it can solve your problem. Or simply try deleting the .nx folder and re-entering the experiment.

ussfranck avatar Oct 02 '24 14:10 ussfranck

Same issue on MacOS Nx: 19.6.5 Node: 22.5.1 MacOS Sonoma: 14.7

jadiaheno avatar Oct 06 '24 19:10 jadiaheno

Same issue here, a colleague of mine can't work on the project on his Windows 11 machine. (I'm on macOS, and I can't reproduce the problem).
So I cloned our work on my Windows machine to see if I can reproduce it there.
Here is my nx report output :

> nx report

 NX   The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected.


 NX   Report complete - copy this into the issue template

Node           : 20.13.1
OS             : win32-x64
Native Target  : wasm32
npm            : 10.5.2

nx                 : 19.5.6
@nx/js             : 19.5.6
@nx/jest           : 19.5.6
@nx/linter         : 19.5.6
@nx/eslint         : 19.5.6
@nx/workspace      : 19.5.6
@nx/angular        : 19.5.6
@nx/cypress        : 19.5.6
@nx/devkit         : 19.5.6
@nx/esbuild        : 19.5.6
@nx/eslint-plugin  : 19.5.6
@nx/express        : 19.5.6
@nx/nest           : 19.5.6
@nx/node           : 19.5.6
@nrwl/tao          : 19.5.6
@nx/web            : 19.5.6
@nx/webpack        : 19.5.6
typescript         : 5.4.5
---------------------------------------
Community plugins:
@fortawesome/angular-fontawesome : 0.14.0
ng-extract-i18n-merge            : 2.10.0
ngx-toastr                       : 17.0.2
nx-stylelint                     : 17.1.5

An issue pops from nowhere from time to time, and it really affects the quality of life of the developers who encounter this kind of issues. Tell me if I can help you with that!

On my end I tried to get a fresh git clone, fresh npm i, re-generate the package-lock.json but nothing works.

Rafarel avatar Oct 09 '24 15:10 Rafarel

⭐️ Follow-up to my previous message:
We switched from using npm to pnpm, and that fixed the issue! Does this solve your problem too?

Rafarel avatar Oct 10 '24 12:10 Rafarel