-
Notifications
You must be signed in to change notification settings - Fork 257
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. #380
Comments
I tried
None of those above worked |
error log
|
Go back to the 7.0.1 version |
Yes this is what I did for now. So there will be no support for typescript in future ? |
same for javascript here |
Same issue, tested multiple node versions , none is working. Downgrading to ^7.0.1 again works. |
This is still an issue, even reverting back to ^7.0.1 still causes this issue.
|
Going back to That kinda sucks. There aren't many good alternatives out there for programmatic image processing. This repo is now Don't get me wrong, I think ESM is the way to go, but for many projects it will require (ha, ha) a lot of work. I use |
Its still not working this way in typescript
Error
|
I am working on migrating over to @squosh/cli, for the time being I will have to revert back to require + v7.0.1, thanks 👍 |
@krishnaTORQUE I was able to get it to compile in ts like so: package.json
src/main.ts
then compile
So I'm not sure why it doesn't work for you! |
@benjaminboruff thank you for your reply. I am very much unsure about it. |
@krishnaTORQUE sorry, I should have specified ... I am using But, yeah, sadly I think we all need to find a different package :( |
I don't know if you guys figured out the solution, but I just changed the file extension from js to mjs and replace the require with import, and then everything works fine with version 8. webp.mjs
and run |
Your solution won't work in Typescript |
This issue has not been solved in |
Because the imagemin 8 version is now pure ESM. const imageminJpegtran = require('imagemin-jpegtran');
async function main() {
const imagemin = (await import('imagemin')).default;
const files = await imagemin(['images/*.{jpg,png}'], {
destination: 'build/images',
plugins: [imageminJpegtran()]
});
}
main(); |
Awesome. That resolved the issue in typescript too |
Not for me. It just postponed error until the dynamic import. Last working version for me is still 7.X.
No it is not 7.1.0. It is 7.0.1. Last 4 versions on npm are: 8.0.1, 8.0.0, 7.0.1, 7.0.0 |
No, it's not 7.0.1, it is 7.1.0. The info on the site is irrelevant(and wrong in this case, too), it's not part of the actual package manager, it's just a website. Apparently, looks like they have wrong info on their website, which is not to be confused with actual package manager: npm. You cannot download imagemin of version 7.0.1 from npm, as I shown above on the screenshot. When you enter what versions are available, there is no 7.0.1: And you can't download it either, you'll get the error. |
@KulaGGin that npm information is for the |
2023 here - going back to version 7.0.1 works. Cheers |
This solution works for me. Thank you very mich!!! |
After update to latest version I got this error
require() of ES modules is not supported.
I am using typescript
The text was updated successfully, but these errors were encountered: