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

ERR_REQUIRE_ESM: Supporting ES Modules #48

Open
austen-wade opened this issue Oct 16, 2022 · 2 comments
Open

ERR_REQUIRE_ESM: Supporting ES Modules #48

austen-wade opened this issue Oct 16, 2022 · 2 comments

Comments

@austen-wade
Copy link

austen-wade commented Oct 16, 2022

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
Copy link
Author

adobe/aem-project-archetype#886
Looks like the switch to ES Modules is somewhat in progress on the archetype

@zxhmike
Copy link

zxhmike commented Feb 26, 2024

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

  • Rename clientlib.config.js to clientlib.config.cjs
  • In the "scripts" section of package.json, explicitly provide the new config file name. e.g.
    "prod": "npm run build && clientlib clientlib.config.cjs --verbose",

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