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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #56

Closed
JBaczuk opened this issue Nov 5, 2021 · 2 comments
Closed

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #56

JBaczuk opened this issue Nov 5, 2021 · 2 comments

Comments

@JBaczuk
Copy link

JBaczuk commented Nov 5, 2021

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch imagemin-svgo@10.0.0 for the project I'm working on.

This fixes a build error with next.js and the ERR_REQUIRE_ESM error.

https://github.com/vercel/next.js/issues/30307

Here is the diff that solved my problem:

diff --git a/node_modules/imagemin-svgo/index.js b/node_modules/imagemin-svgo/index.cjs
similarity index 100%
rename from node_modules/imagemin-svgo/index.js
rename to node_modules/imagemin-svgo/index.cjs

This issue body was partially generated by patch-package.

@dchiang
Copy link

dchiang commented Nov 8, 2021

When running yarn build I got the same error with the same suggestion your are making or to remove "type": "module" from the package.json file in node_modules/imagemin-svgo/. I decided to go with the first suggestion and changed the index file type of imagemin-svgo to .cjs and now my project is running locally but I am still wondering why did it work and if there will be any impact before releasing it.

Javascript, NodeJS and all the libraries/frameworks derived from or related to them are not my area of expertise so I would really appreciate some insight reggarding this issue.

@webketje
Copy link
Member

webketje commented May 3, 2024

If you run into this issue, please see the discussion and links at #57

@webketje webketje closed this as completed May 3, 2024
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