imagemin-svgo
imagemin-svgo copied to clipboard
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
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.
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.
If you run into this issue, please see the discussion and links at #57