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

Node ES modules can't import crank #87

Closed
dfabulich opened this issue May 2, 2020 · 1 comment · Fixed by #108
Closed

Node ES modules can't import crank #87

dfabulich opened this issue May 2, 2020 · 1 comment · Fixed by #108
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@dfabulich
Copy link

dfabulich commented May 2, 2020

To reproduce:

I'm running node v14.1.0.

mkdir testesm
cd testesm
npm init -y
npm i @bikeshaving/crank
cat <<EOF > index.mjs
import {createElement} from "@bikeshaving/crank";
import {renderer} from "@bikeshaving/crank/html";

console.log(renderer.render(createElement("div", null, "Hello world")));
EOF
node index.mjs

Expected: The console should show <div>Hello world</div>

Actual:

internal/modules/run_main.js:54
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/private/tmp/tp/testesm/node_modules/@bikeshaving/crank/html' imported from /private/tmp/tp/testesm/index.mjs
    at finalizeResolution (internal/modules/esm/resolve.js:272:11)
    at packageResolve (internal/modules/esm/resolve.js:607:14)
    at moduleResolve (internal/modules/esm/resolve.js:646:14)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:692:13)
    at Loader.resolve (internal/modules/esm/loader.js:97:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
    at link (internal/modules/esm/module_job.js:41:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
@brainkim brainkim added bug Something isn't working help wanted Extra attention is needed labels May 2, 2020
@brainkim
Copy link
Member

brainkim commented May 2, 2020

Sorry to hear about this. Confirming this is an issue with node.js versions 12/13. I am consistently infuriated by how senseless and arcane node.js ESModule support is and can’t seem to figure it out at the moment (1:53AM Saturday for me right now). For some reason, I can’t even import the cjs versions. Is there a resource you know of which just tells me how to support node.js 13 for esmodules?

dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 2, 2020
dfabulich added a commit to dfabulich/crank that referenced this issue May 15, 2020
@dfabulich dfabulich mentioned this issue May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
2 participants