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

Conflict with Gulp Load Plugins #361

Closed
DaveyJake opened this issue Sep 1, 2021 · 4 comments
Closed

Conflict with Gulp Load Plugins #361

DaveyJake opened this issue Sep 1, 2021 · 4 comments

Comments

@DaveyJake
Copy link

The following error message occurs when attempting to load the plugin using gulp-load-plugins:

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

I tried making the basic adjustments as suggested but none worked. Any ideas would be much appreciated.

Cheers 🍻

@bobbyg603
Copy link

Try the following:

  1. npm i esm
  2. rename gulpfile.js to gulpfile.esm.js
  3. Update all your requires to imports
  4. gulp

@strarsis
Copy link

strarsis commented Sep 15, 2021

@bobbyg603: Thanks! However, it doesn't change anything, the error persists. 😞

@bobbyg603
Copy link

bobbyg603 commented Sep 16, 2021

@strarsis i ended up using gulp/typescript to solve this problem and forgot to update my answer, sorry about that! here's a link in the gulp docs that specifies how to use typescript https://gulpjs.com/docs/en/getting-started/javascript-and-gulpfiles/#transpilation

@sindresorhus
Copy link
Owner

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

4 participants