wcm-io-frontend / aem-clientlib-generator

Creates configuration files for AEM ClientLibs and synchronizes assets.
Apache License 2.0
63 stars 32 forks source link

ERR_REQUIRE_ESM: Supporting ES Modules #48

Open austen-wade opened 1 year ago

austen-wade commented 1 year ago

When attempting to use clientlibs-cli inside of a project with a package.json that contains "type": "module", I receive this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /../mysite/ui.frontend/clientlib.config.js from /../.local/share/pnpm/global/5/.pnpm/aem-clientlib-generator@1.8.0/node_modules/aem-clientlib-generator/bin/clientlib-cli.js not supported.
Instead change the require of clientlib.config.js in /../.local/share/pnpm/global/5/.pnpm/aem-clientlib-generator@1.8.0/node_modules/aem-clientlib-generator/bin/clientlib-cli.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/../.local/share/pnpm/global/5/.pnpm/aem-clientlib-generator@1.8.0/node_modules/aem-clientlib-generator/bin/clientlib-cli.js:44:21) {
  code: 'ERR_REQUIRE_ESM'
}
node:internal/errors:841
  const err = new Error(message);

Is there a way to add support for ES Modules?

austen-wade commented 1 year ago

https://github.com/adobe/aem-project-archetype/issues/886 Looks like the switch to ES Modules is somewhat in progress on the archetype

zxhmike commented 5 months ago

Just in case someone googles the error message and comes to this page, this is my solution: