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

Broken in Stackblitz with Error: Cannot load native addon because loading addons is disabled: .../node.napi.glibc.node #92

Closed
seveibar opened this issue Jul 9, 2024 · 6 comments

Comments

@seveibar
Copy link

seveibar commented Jul 9, 2024

Hi everyone,

I didn't see anything on the web about this issue, but it seems like classic-level doesn't work in the Stackblitz environment (many modules don't!)

What's the solution here? Would love a workaround!

image

@vweevers
Copy link
Member

vweevers commented Jul 9, 2024

Currently, WebContainers can only execute languages that are natively supported on the Web, including JavaScript and WebAssembly. It is not possible to run native addons which are usually implemented using native languages such as C++, unless they can be compiled to WebAssembly. Therefore, loading native addons is disabled by default via --no-addons in WebContainers. As a result, you may encounter an error that says: Cannot load native addon because loading addons is disabled.

The solution to this is to use an alternative to the native addon which is either fully implemented in JavaScript or can be compiled to WebAssembly.
https://developer.stackblitz.com/platform/webcontainers/troubleshooting-webcontainers

TLDR, it's simply not supported.

@seveibar
Copy link
Author

seveibar commented Jul 9, 2024

@vweevers I was thinking of writing a levels module that could work in these environments- I saw that some people have done this in the past but they are a bit dated. Curious if there's a "popular" way to use levels in NodeJS without native addons.

@seveibar
Copy link
Author

seveibar commented Jul 9, 2024

Maybe this issue doesn't belong on this repo too since it's definitely not something I think classic-levels should add support for (I think?), but I did want to help with the SEO to direct people (if there is a common alternative)

@mcollina
Copy link
Member

mcollina commented Jul 9, 2024

doesn't work in the Stackblitz environment

Stackblitz is a fork of Node.js, not Node.js itself.

@seveibar
Copy link
Author

seveibar commented Jul 9, 2024

@mcollina do you think anyone cares about using level in environments that don't support native/c addons? I have no idea if it's common. I can understand that "if you don't support native addons you kind of aren't NodeJS- it's an issue for stackblitz etc."

(fwiw I'm also ok w/ closing this issue/seeing if other people stumble on it over time?)

I ended up using memory-level because persistence wasn't super important for my app.

@vweevers
Copy link
Member

vweevers commented Jul 9, 2024

I don't know if StackBlitz provides access to web APIs like IndexedDB but if they do then browser-level is probably the best option, if you do need persistence. An alternative is Level/community#63.

In any case, we can't add support for StackBlitz in classic-level because this module is specifically for Node.js.

@vweevers vweevers closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants