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

require() of ES Module prettier-plugin-curlylib/index.js is not supported #545

Closed
3 tasks done
Tawpie opened this issue Jul 3, 2024 · 8 comments · Fixed by #577
Closed
3 tasks done

require() of ES Module prettier-plugin-curlylib/index.js is not supported #545

Tawpie opened this issue Jul 3, 2024 · 8 comments · Fixed by #577
Assignees
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(

Comments

@Tawpie
Copy link

Tawpie commented Jul 3, 2024

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

Plugin should run without error

Actual

Error [ERR_REQUIRE_ESM]: require() of ES Module [redacted]/node_modules/prettier-plugin-curly/lib/index.js from [redacted]/node_modules/prettier/index.js not supported.
Instead change the require of [redacted]/node_modules/prettier-plugin-curly/lib/index.js in [redacted]/node_modules/prettier/index.js to a dynamic import() which is available in all CommonJS modules.
at c._load (node:electron/js2c/node_init:2:13672)

Additional Info

happens with node 18.18.0 and 20.15.0

@Tawpie Tawpie added the type: bug Something isn't working :( label Jul 3, 2024
@JoshuaKGoldberg
Copy link
Owner

Works on my machine. Could you please post an isolated reproduction where I can reproduce your issues?

https://antfu.me/posts/why-reproductions-are-required

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Jul 3, 2024
@markof94
Copy link

I had this same error just now after setting up Storybook on my Nextjs project.

Reverting to ^0.1.3 stops the error from happening.

@JoshuaKGoldberg
Copy link
Owner

on my Nextjs project

@markof94 prove it! 🙂 (please)

@markof94
Copy link

on my Nextjs project

@markof94 prove it! 🙂 (please)

Hey, I managed to recreate it on a blank Next project. I copied over the packages from my original project's package.json and the same prettier and eslint configs.
Here's the repo. Hope it helps!

image

@JoshuaKGoldberg
Copy link
Owner

Super, thanks - I can repro with that! Much appreciated!

The root issue is roughly what Prettier is hinting: that node_modules/prettier-plugin-curly/lib/index.js has ESM imports and exports, but the project around it is not type: "module".

In other words, roughly https://github.com/JoshuaKGoldberg/create-typescript-app/blob/0a4c50f93c690af12356a9c99a7079ecb6da3a6f/docs/FAQs.md#how-can-i-add-dual-commonjs--ecmascript-modules-emit is needed. I'll do that real quick now. Thanks all!

@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jul 17, 2024
@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Please, send a pull request to resolve this! and removed status: waiting for author Needs an action taken by the original poster labels Jul 17, 2024
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @Tawpie for bug.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @Tawpie! 🎉

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@JoshuaKGoldberg
Copy link
Owner

👋 this should be fixed in prettier-plugin-curly@0.2.2. Please let me know if you have a reproduction of it still being broken. Thanks again everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants