-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Node.js errors when running emconfigure ./configure
when there exists a package.json
with type: "module"
#24244
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
Comments
Yeah it kind of sucks that node doesn't support forcing commonjs from the command line. I guess one possible solution would be to convert all configure tests to use |
Yeah, I'm empathetic that this issue isn't on Emscripten's end and is more of a quirk of Node.js. Personally, I'm fine with my solution of just running |
When you say "autodetecting module syntax" do you mean looking at the syntax of the file? I was thinking node would just look at the file extension ".mjs"? |
Oh, sorry to clarify, I believe the issue in this case is the lack of file extension — the error that occurs happens when |
Are there flags we can pass to node to force |
Not to my knowledge — I tried it with I figure the best bet for compatibility would be to see if createRequire can be used to polyfill |
We do use Lines 113 to 121 in b277d57
|
I wonder if we can get this bug re-opened: nodejs/node#44457 |
Another possible solution: Put the JS in a |
Actually — I realize you can pass options to |
Right, is a workaround, but it depends on you knowing to match your configure args with the nearest |
FWIW, this was previously reported in #13551 and #17431. Setting the |
OK lets close this in favor of #13551 |
Version
emscripten/[email protected]
Description
Suppose you had the following files:
configure.ac
,dummy.c
, and apackage.json
withtype: "module"
. This is true even if thatpackage.json
is not in the same directory as./configure
but only the closestpackage.json
.Failing command line in full:
autoreconf && emconfigure ./configure
(or any variation that uses autoconf)Terminal output:
config.log
output snippet: (full output, full output withEMCC_DEBUG=1
)Indeed, if you remove
type: "module"
frompackage.json
,config.log
will be able to proceed past that test anda.wasm
,config.status
will be generated.Hence, the failing command seems to be
emcc -o conftest conftest.c >&5
. I have linked the pastebins for the output of the generated filesconftest
andconftest.c
.I believe the reason this occurs is that a feature was added in Node.js v21.0.0 to automatically run extensionless JavaScript as modules based on the nearest
package.json
(see nodejs/node#49974). This was backported to Node.js v20.10.0 (nodejs/node#50682).I haven't found any solutions for this other than generating a
package.json
in theconfigure
directory withnpm init --yes
or removingtype: "module"
altogether. Setting--experimental-default-type=commonjs
doesn't seem to fix it.EDIT:
Alternatively,
emconfigure ./configure CFLAGS='-sEXPORT_ES6=1'
(orLDFLAGS
,LIBS
,CPPFLAGS
) will work as intended.The text was updated successfully, but these errors were encountered: