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

Corepack doesn't properly set up Yarn in an ESM project #604

Open
Supinic opened this issue Jan 20, 2025 · 0 comments
Open

Corepack doesn't properly set up Yarn in an ESM project #604

Supinic opened this issue Jan 20, 2025 · 0 comments

Comments

@Supinic
Copy link

Supinic commented Jan 20, 2025

After refactoring my project built with Corepack + Yarn 4.6 to ESM syntax including the type: "module" setting in package.json, no yarn commands work any more and throw an error:

Error: Dynamic require of "util" is not supported

I'm not particularly sure about the cause (Yarn tracks a similar issue: yarnpkg/berry#5831) but it only really seems to happen for me if I use Corepack to initialize Yarn within a blank Docker image.

On a system where global Yarn is using a .cjs file, all operations work as expected, so I'm leaning towards it being a Corepack issue, though I don't know either environment well enough to be sure. It could also be a combination of conflicting settings, I'm not sure.

I also created a simple Docker example in this repository for easier replication: https://github.com/Supinic/test-corepack-yarn-esm

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

1 participant