You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# node -v
v20.18.0
# which node
/emsdk/node/20.18.0_64bit/bin/node
Description
Suppose you had the following files: configure.ac, dummy.c, and package.json. (Note: this is true even if package.json is not in the root directory, only such that the nearest package.json to cwd has type: module.)
autoreconf && emconfigure ./configure (or any variation that uses autoconf)
Terminal output:
configure: ./configure
checking for gcc... /emsdk/upstream/emscripten/emcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/src':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
emconfigure: error: './configure' failed (returned 77)
# config.log...configure:2721: checking whether we are cross compilingconfigure:2729: /emsdk/upstream/emscripten/emcc -o conftest conftest.c >&5configure:2733: $? = 0configure:2740: ./conftestfile:///src/conftest:79 var fs = require('fs'); ^ReferenceError: require is not defined in ES module scope, you can use import instead at file:///src/conftest:79:12 at ModuleJob.run (node:internal/modules/esm/module_job:234:25) at async ModuleLoader.import (node:internal/modules/esm/loader:473:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)Node.js v20.18.0configure:2744: $? = 1configure:2751: error: in `/src':configure:2753: error: cannot run C compiled programs.If you meant to cross compile, use `--host'.
Indeed, if you remove the type: module from package.json, config.log will look like this:
configure:2721: checking whether we are cross compiling
configure:2729: /emsdk/upstream/emscripten/emcc -o conftest conftest.c >&5
configure:2733: $? = 0
configure:2740: ./conftest
configure:2744: $? = 0
configure:2759: result: no
configure:2764: checking for suffix of object files
and a.wasm, config.status will be generated.
In regards to conftest, this is the the output of/emsdk/upstream/emscripten/emcc -o conftest conftest.c and conftest.c is
I haven't found any solutions for this other than generating a package.json in the build directory with npm init --yes or deleting that type: "module".
The text was updated successfully, but these errors were encountered:
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 .mjs and ES modules? Would using the .mjs extensions for ES module mode even if type: module were not in the package.json? i.e. does mjs force module mode?
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 .mjs and ES modules? Would using the .mjs extensions for ES module mode even if type: module were not in the package.json? i.e. does mjs force module mode?
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 npm init --yes in any directories with a configure script since from what I can tell, while autodetecting module syntax is now unflagged (as of v22.7.0), it's still not recommended due to a bit of overhead and adding type: "module" to ES packages is still recommended.
Version
emscripten/[email protected]
Description
Suppose you had the following files: configure.ac, dummy.c, and package.json. (Note: this is true even if
package.json
is not in the root directory, only such that the nearestpackage.json
to cwd hastype: module
.)Failing command line in full:
autoreconf && emconfigure ./configure
(or any variation that uses autoconf)Terminal output:
Snippet of output of
config.log
(full output here: https://pastebin.com/mWuRPrUP, or with EMCC_DEBUG=1 here: https://pastebin.com/aDECYhHk)Indeed, if you remove the
type: module
frompackage.json
, config.log will look like this:and
a.wasm
,config.status
will be generated.In regards to conftest, this is the the output of
/emsdk/upstream/emscripten/emcc -o conftest conftest.c
and conftest.c isI believe the reason this occurs is that a feature was added to automatically detect extensionless modules based on the nearest
package.json
in v21.0.0, and this was backported to 20.10.0. Setting--experimental-default-type=commonjs
doesn't seem to fix it though.I haven't found any solutions for this other than generating a package.json in the build directory with
npm init --yes
or deleting thattype: "module"
.The text was updated successfully, but these errors were encountered: