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

Incompatibility issue with node v16? #50

Open
bchevalier opened this issue Jul 14, 2023 · 1 comment
Open

Incompatibility issue with node v16? #50

bchevalier opened this issue Jul 14, 2023 · 1 comment

Comments

@bchevalier
Copy link

I had to use v6 of imagemin-webp as using v7 or v8 would lead to the following error at build time:

/.../src/index.js:12
const imagemin_webp_1 = __importDefault(require("imagemin-webp"));
                                        ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /.../node_modules/imagemin-webp/index.js from /.../src/index.js not supported.
Instead change the require of /.../node_modules/imagemin-webp/index.js in /.../src/index.js to a dynamic import() which is available in all CommonJS modules.

Note that I am using node v16.20.1 and npm v8.19.4

@Bengejd
Copy link

Bengejd commented Apr 3, 2024

I know this is an old thread, but I recently ran across this. I had to move the import into my function and import it dynamically instead of requiring it.

gulp.task("convertToWebp", async () => {
  const imagemin = (await import("gulp-imagemin")).default;
  const imageminWebp = (await import("imagemin-webp")).default;
  ...
});

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

2 participants