stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.78k stars 144 forks source link

WebContainer for Analog fails to load due to transitive parcel dependency #916

Closed brandonroberts closed 1 year ago

brandonroberts commented 1 year ago

Describe the bug

When the StackBlitz launches, finishes installing dependencies and runs npm run dev, an error is thrown about a parcel dependency, which we do not directly depend on.

An unhandled exception occurred: Cannot load native addon because loading addons is disabled: /home/projects/parirrgam.github/node_modules/@parcel/watcher/prebuilds/linux-x64/node.napi.glibc.node See "/tmp/ng-4E3yAE/angular-errors.log" for further details.

Link to the blitz that caused the error

https://stackblitz.com/github/analogjs/analog/tree/main/packages/create-analog/template-angular-v15?file=vite.config.ts&preset=node

Steps to reproduce

  1. Visit the StackBlitz link above
  2. Note the error when trying to run npm run dev
  3. Run the vite command in the terminal
  4. Note the application starts up correctly

Expected behavior

The npm run dev command works on initial load

Parity with Local

Screenshots

No response

Platform

Additional context

StackBlitz is also linked from https://analogjs.org/new

d3lm commented 1 year ago

Hey Brandon 👋 Thanks for open this issue. The problem is that there's a dependency on @parcel/watcher which is a native addon, and native addons cannot be loaded and executed in a browser. There's been a discussion here, but since then the lib doesn't provide a fallback for environments that don't support native addons. As an interim solution I'd suggest to remove that dependency maybe, or dynamically require it based on the environment.

Nemikolh commented 1 year ago

Hi Brandon! :smiley:

I'm going to close this issue as we can't do much at this point in time. Please feel free to reopen it, if you think we misunderstood the issue or if there's anything you think we could do that could help with your problem.

brandonroberts commented 1 year ago

Thanks @Nemikolh. I'll see what I can do there. I'm getting a different error on a known dependency now.

An unhandled exception occurred: Cannot load native addon because loading addons is disabled: /home/projects/jvmigzplk.github/node_modules/@nrwl/nx-linux-x64-musl/nx.linux-x64-musl.node See "/tmp/ng-T8DSYV/angular-errors.log" for further details.

errors.log

[error] Error: Cannot load native addon because loading addons is disabled: /home/projects/jvmigzplk.github/node_modules/@nrwl/nx-linux-x64-musl/nx.linux-x64-musl.node at process.dlopen (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:15:109711) at Module._extensions..node (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:220123) at Module.load (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:217771) at Module._load (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:215342) at Module.require (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:218089) at i (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:419524) at _0xd2b7ec (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:15:140722) at Object.eval (file:///home/projects/jvmigzplk.github/node_modules/nx/src/native/index.js:171:31) at Object.function (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:15:141457) at Module._compile (https://jvmigzplkgithub-wx5i.w-credentialless.staticblitz.com/blitz.6df6cd42ba0b81666017ec43c5c96e159ca2f943.js:6:219081)

I'll see what my options are.