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 ... not supported. #159

Open
marikaner opened this issue Apr 24, 2024 · 2 comments
Open

Comments

@marikaner
Copy link

marikaner commented Apr 24, 2024

We use cliui transitively through jest, which is a CJS module. Currently, when running jest in our project, we get the following error:

Error [ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/string-width/index.js from [...]/node_modules/cliui/build/index.cjs not supported.

I believe this is because of these lines.
Instead string-width and string-ansi, string-width-cjs' and string-ansi-cjsshould be required. Those are already installed. However, the third dependencywrap-ansi` does not exist as a CJS dependency.

@shadowspawn
Copy link
Member

Short version: Are you using yarn 1? Try upgrading to yarn v1.22.22 or higher.

Long version

The problem isn't actually in this repo. Or at least, not yet.

PR #139 uses package aliases to pull in two different versions of string-width et al to add wrapping support for esm. It is published as @isaacs/cliui from a cliui fork and is used as a dependency of JackSpeak. The aliases can trigger broken dependency resolution with Yarn 1.

@marikaner
Copy link
Author

With a closer look I realized the problem might not be this package because I got the same issue with another. I was in fact using yarn 1.22.19. Thanks for the tip!

mnvr added a commit to ente-io/ente that referenced this issue May 1, 2024
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