1000ch / gulp-image

Optimize PNG, JPEG, GIF, SVG images with gulp task.
http://bit.ly/we-should-optimize-images
MIT License
223 stars 22 forks source link

Don't work - Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #142

Open my-user-git opened 2 years ago

my-user-git commented 2 years ago

$ gulp Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...\06_test_Gulp\node_modules\gulp-image\index.js require() of ES modules is not supported. require() of ...\06_test_Gulp\node_modules\gulp-image\index.js from ...\06_test_Gulp\gulpfile.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.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from ...\06_test_Gulp\node_modules\gulp-image\package.json.

at new NodeError (node:internal/errors:363:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1126:13)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (...\06_test_Gulp\gulpfile.js:7:15)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32) {

code: 'ERR_REQUIRE_ESM' }

jbsmith731 commented 2 years ago

Same here. I was able to downgrade to 6.2.1 and get it running.

my-user-git commented 2 years ago

Thank you very much! Downgraded the version now the error does not appear, I check whether the plugin works

jbsmith731 commented 2 years ago

Duplicate of #139

jbsmith731 commented 2 years ago

@elcaptain I believe it should be npm install gulp-image@6.2.1.

elcaptain commented 2 years ago

@jbsmith731 yes, thanks. I noticed it myself shortly after so i deleted my original post, sorry ^^" I can report that downgrading solved my error too.