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

Error [ERR_REQUIRE_ESM]: require() of ES Module #23

Closed
mesqueeb opened this issue Jan 24, 2022 · 3 comments
Closed

Error [ERR_REQUIRE_ESM]: require() of ES Module #23

mesqueeb opened this issue Jan 24, 2022 · 3 comments

Comments

@mesqueeb
Copy link
Owner

I tried 2.1.3 in my package and I ran into this error:

} = require("case-anything");
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/Sites/asyncapi-format/node_modules/case-anything/dist/index.umd.js from /Users/Sites/asyncapi-format/asyncapi-format.js not supported.
index.umd.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename index.umd.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/Sites/asyncapi-format/node_modules/case-anything/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.<anonymous> (/Users/Sites/asyncapi-format/asyncapi-format.js:21:5)
    at Object.<anonymous> (/Users/Sites/asyncapi-format/bin/cli.js:5:24) {
  code: 'ERR_REQUIRE_ESM'

Version 2.1.2 works without a problem.

Originally posted by @thim81 in #20 (comment)

@mesqueeb
Copy link
Owner Author

@thim81 fixed in latest version 🎉

@mesqueeb
Copy link
Owner Author

image

@thim81
Copy link

thim81 commented Jan 24, 2022

I have just update my project to use the latest version case-anything.
🙌 for solving the es module problem.

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