-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Regression in "require" in ES6 modules. Fails to find "ws" module. #23503
Comments
Interesting. I assumed that the parameter to |
Just to confirm, are you trying to actually build websocket server using emscripten that runs in node? Or is this code just getting included incidentally somehow? |
Thanks for the quick reply! And yes. I am building a websocket server using emscripten. (Well, I'm porting a POSIX socket server). |
The fix seems easier enough, although I'm having trouble being able to test this (because out test code sets NODE_PATH=..., which obviates the need for the fix). Can you say more about your use case. Are you running your emscripten-generate code both in node and in the browser? |
For most uses of `require()` in emscripten this does not matter since we load mostly system libraries. However for the `ws` module it is needed. This bug was being masked by the fact that we were setting `NODE_PATH` in our socket test running. This is no longer needed now that we run (non-parallel) tests in the emscripten tree (in out/test). This is followup to emscripten-core#23265 which itself was an attempt to revert 23169. Fixes: emscripten-core#23503
For most uses of `require()` in emscripten this does not matter since we load mostly system libraries. However for the `ws` module it is needed. This bug was being masked by the fact that we were setting `NODE_PATH` in our socket test running. This is no longer needed now that we run (non-parallel) tests in the emscripten tree (in out/test). This is followup to emscripten-core#23265 which itself was an attempt to revert 23169. Fixes: emscripten-core#23503
For most uses of `require()` in emscripten this does not matter since we load mostly system libraries. However for the `ws` module it is needed. This bug was being masked by the fact that we were setting `NODE_PATH` in our socket test running. This is no longer needed now that we run (non-parallel) tests in the emscripten tree (in out/test). This is followup to emscripten-core#23265 which itself was an attempt to revert 23169. Fixes: emscripten-core#23503
For most uses of `require()` in emscripten this does not matter since we load mostly system libraries. However for the `ws` module it is needed. This bug was being masked by the fact that we were setting `NODE_PATH` in our socket test running. This is no longer needed now that we run (non-parallel) tests in the emscripten tree (in out/test). This is followup to emscripten-core#23265 which itself was an attempt to revert 23169. Fixes: emscripten-core#23503
For most uses of `require()` in emscripten this does not matter since we load mostly system libraries. However for the `ws` module it is needed. This bug was being masked by the fact that we were setting `NODE_PATH` in our socket test running. This is no longer needed now that we run (non-parallel) tests in the emscripten tree (in out/test). This is followup to emscripten-core#23265 which itself was an attempt to revert 23169. Fixes: emscripten-core#23503
It looks like a recent change to revert a commit that removed uses of
require
didn't quite fully revert to the old behavior.I was getting a bizarre error where Node would refuse to find the "ws" module even though I had installed it using
npm install ws
. I build my code using-sMODULARIZE -sEXPORT_ES6
. The error was:"ws" was getting imported from libsockfs.js in the
listen
function:The original code that was initially reverted called
createRequire
like this:However, the change that re-introduced the old code instead introduced it as:
I'm not very familiar with Javascript and Node, but after much head-scratching, I tracked it down to that piece of code. If I replace the
createRequire
with the original version (the one that first checks for "data:"), my code works!I can create a simple PR to do that fix if needed.
Thanks!
The text was updated successfully, but these errors were encountered: