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

ReferenceError: __dirname is not defined when building as ES 6 module using node 14 #13037

Closed
kjlubick opened this issue Dec 14, 2020 · 2 comments

Comments

@kjlubick
Copy link
Contributor

I am trying to build CanvasKit using ES 6 modules as a result of the discussion in #12952

However, when I try to run my test code in node.js, I see the error

ReferenceError: __dirname is not defined

Which comes from the generated JS code around here:

if (ENVIRONMENT_IS_NODE) {
  if (ENVIRONMENT_IS_WORKER) {
    scriptDirectory = require('path').dirname(scriptDirectory) + '/';
  } else {
    scriptDirectory = __dirname + '/';
  }

I talked with @RReverser and from that conversation:

If updating to 2.0.10 still doesn't work, then it's Emscripten bug that needs to be fixed (it probably assumes that Node.js never runs ES6 modules, which it does now and needs a feature detection to choose between __dirname and import.meta.url)

(I made sure I was using 2.0.10 and the issue still persists).

@sbc100
Copy link
Collaborator

sbc100 commented Dec 14, 2020

Looks like others have noticed this too: #11792

@RReverser
Copy link
Collaborator

@sbc100 Oh yeah, looks like this is a duplicate then.

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

No branches or pull requests

3 participants