-
Notifications
You must be signed in to change notification settings - Fork 745
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
[Unit tests] ReferenceError: require is not defined in ES module scope #6240
Comments
Which node.js version are you using? I think I saw this before and it depends on the node version, but I don't remember if newer or older versions show the error. |
I'm using v20.11.0 |
Thanks, I can't reproduce the issue though:
That runs all the unit tests with node 20.11, and they pass. Which test specifically fails for you? |
Just for clarity, in your test did you add a |
No, I was trying to first see the error before seeing if that fixes it. To make sure I verified there is no such file in the directory, nor any parent. |
No, what I mean is, to reproduce this error, there should be I edited the original issue comment to be a little more precise about this fact. |
I see, apologies for my confusion. That was probably obvious to someone that knows more JS, unlike me 😄 I can reproduce and see the proposed fix works. Opened #6245 |
No worries, I'm also a JS newcomer. 😄 Thanks for your quick feedback and resolution! |
The JS there is not an ES6 module, so declare it so (otherwise a package.json in a parent, perhaps in folders outside of our own project that we are pasted in, can cause an error, as require does not work in ES6 modules and we might be forced to be seen as one). Fixes #6240
The JS there is not an ES6 module, so declare it so (otherwise a package.json in a parent, perhaps in folders outside of our own project that we are pasted in, can cause an error, as require does not work in ES6 modules and we might be forced to be seen as one). Fixes WebAssembly#6240
Hello there. I'm doing a build of binaryen as a dependency of an npm package. Running
check.py
fails because thetest/unit/input/asyncify.js
cannot be run by nodejs when the nearest parent directory which containspackage.json
is configured with"type": "module"
. The error message from executing it directly is:The solution is either adding a
package.json
with an empty configuration ({}
) to thetest/unit/input
directory or changing the script extension to.cjs
.The text was updated successfully, but these errors were encountered: