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

require() of ES modules is not supported #1045

Closed
icaroxavier opened this issue Dec 3, 2021 · 6 comments
Closed

require() of ES modules is not supported #1045

icaroxavier opened this issue Dec 3, 2021 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@icaroxavier
Copy link

icaroxavier commented Dec 3, 2021

After fresh install of yarn add dwv i keep getting this error

require() of ES modules is not supported, require() of E:\dev\colono-front\node_modules\konva\lib\index-node.js from E:\dev\colono-front\node_modules\dwv\dist\dwv.min.js is an ES module file as it is a .js file whose nearest parent package.json

@arturojain
Copy link

arturojain commented Dec 3, 2021

Is this happening with the latest v0.30.1?

@ivmartel ivmartel added the question Further information is requested label Dec 7, 2021
@ivmartel
Copy link
Owner

ivmartel commented Dec 7, 2021

I guess you are using dwv v0.30.1. What is your version of node? If there is more text to the error, can you post it all please?

@ivmartel
Copy link
Owner

ivmartel commented Dec 7, 2021

Ok, cofirmed, I can reproduce with node v15 and the full error is:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /app/available_modules/1638865486000/dwv/node_modules/konva/lib/index-node.js
require() of ES modules is not supported.
require() of /app/available_modules/1638865486000/dwv/node_modules/konva/lib/index-node.js from /app/available_modules/1638865486000/dwv/dist/dwv.min.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index-node.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /app/available_modules/1638865486000/dwv/node_modules/konva/package.json.

@ivmartel ivmartel modified the milestone: 0.30.2 Dec 7, 2021
@ivmartel
Copy link
Owner

ivmartel commented Dec 7, 2021

It looks like, since v12, node allows to load ES modules via import() (see doc). Node will give an error if an ES module is loaded with require.

Konva is a module since its v8 witch was included in dwv v0.30, it needs to be included with import.

@ivmartel ivmartel removed the question Further information is requested label Dec 7, 2021
@ivmartel
Copy link
Owner

ivmartel commented Dec 7, 2021

I just published v0.30.2! I hope it helps...

@ivmartel
Copy link
Owner

ivmartel commented Dec 9, 2021

Ok, it helps but does not go much further, see #1055.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants