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 #7185

Closed
arantebw opened this issue Sep 14, 2023 · 2 comments
Closed

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

arantebw opened this issue Sep 14, 2023 · 2 comments

Comments

@arantebw
Copy link

arantebw commented Sep 14, 2023

What minimal example or steps are needed to reproduce the bug?

yarn lint

What minimal configuration is needed to reproduce the bug?

Using:

  • yarn 1.22.19
  • node 18.16.0

How did you run Stylelint?

    "lint": "yarn prettier --check && yarn eslint && yarn stylelint && yarn markdownlint",

Which Stylelint-related dependencies are you using?

    "stylelint": "^15.10.3",

What did you expect to happen?

Lint won't return a runtime error.

What actually happened?

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/user1/Projects/project1/node_modules/string-width/index.js from /Users/user1/Projects/project1/node_modules/stylelint/lib/formatters/stringFormatter.js not supported.
Instead change the require of index.js in /Users/user1/Projects/project1/node_modules/stylelint/lib/formatters/stringFormatter.js to a dynamic import() which is available in all CommonJS modules.

Do you have a proposal to fix the bug?

Upgrade string-width to its latest version.

Currently used by stylelint:
Screenshot 2023-09-14 at 14 13 26

Latest version available:
Screenshot 2023-09-14 at 14 13 52

@ybiquitous
Copy link
Member

@arantebw Thanks for opening the issue using the template. I'm afraid that Stylelint v15 doesn't support ESM yet, so stylelint@15.10.3 needs to use older versions of string-width. See also the dependencies restriction below:

$ npm v stylelint@15.10.3 'dependencies.string-width'
^4.2.3

But we are moving to ESM (#5291) and will support ESM in the next major version (v16.0.0).

@arantebw
Copy link
Author

I appreciate the reply and the info. Thanks! 🙏🏼

@ybiquitous ybiquitous closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants