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

emconfigure fails inside "type": "module" package #13551

Open
aduh95 opened this issue Feb 23, 2021 · 4 comments · May be fixed by #17451
Open

emconfigure fails inside "type": "module" package #13551

aduh95 opened this issue Feb 23, 2021 · 4 comments · May be fixed by #17451

Comments

@aduh95
Copy link
Contributor

aduh95 commented Feb 23, 2021

Repro:

$ echo '{"type":"module"}' > package.json
$ curl -L https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.xz | tar -xJ
$ cd expat-2.2.10
$ emconfigure ./configure
configure: ./configure
checking build system type... x86_64-apple-darwin20.3.0
checking host system type... x86_64-apple-darwin20.3.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... conftools/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
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 `…/expat-2.2.10':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

And in config.log:

configure:3744: checking whether we are cross compiling
configure:3752: …/emsdk/upstream/emscripten/emcc -o conftest    conftest.c  >&5
configure:3756: $? = 0
configure:3763: ./conftest
(node:90074) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
    internalBinding('errors').triggerUncaughtException(
                              ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for …/expat-2.2.10/conftest
    at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:65:15)
    at Loader.getFormat (internal/modules/esm/loader.js:113:42)
    at Loader.getModuleJob (internal/modules/esm/loader.js:244:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Loader.import (internal/modules/esm/loader.js:178:17) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
configure:3767: $? = 1
configure:3774: error: in `…/expat-2.2.10':
configure:3776: error: cannot run C compiled programs.

This could be solved if emconfigure added a package.json file in the current directory:

{ "type" : "commonjs" }
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@shamrin
Copy link
Contributor

shamrin commented Jul 15, 2022

@aduh95 I've stumbled upon a similar problem in #17431. Library is different, symptoms are different. But the underlying cause and the exception in config.log are the same.

@stale stale bot removed the wontfix label Jul 15, 2022
@sbc100
Copy link
Collaborator

sbc100 commented Jul 15, 2022

I see, it looks like the "#!" line that runs the emscripten "executables" under node is effected by package.json files. I guess we could/should override that in the #!?

shamrin added a commit to shamrin/emscripten that referenced this issue Jul 15, 2022
This fixes hard-to-debug failures when any parent directory has
package.json with {"type": "module"} in it.

Before emconfigure / conftest could fail with config.log error:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ""

The fix forces commonjs mode for generated Node scripts.

fixes emscripten-core#13551
fixes emscripten-core#17431
@dsogari
Copy link

dsogari commented Jan 20, 2024

Please see my #17451 (comment) for a possible fix.

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

Successfully merging a pull request may close this issue.

4 participants