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

How to fix "Uncaught Error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"? #149

Open
slishnevsky opened this issue Jan 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@slishnevsky
Copy link

slishnevsky commented Jan 31, 2024

I have read related posts and similar questions.

But I haven't found the solution of how to still use require().

The reason is that I downloaded Twitter API examples project and for all files they use require().

https://github.com/twitterdev/Twitter-API-v2-sample-code

So I don't want to mess with all these files, besides changing require() to import() breaks the code.

Instead I need to know if I can make any changes to configuration so that these example script would run.

I have changed "type" to "commonjs" in package.json but it hasn't resolved the problem. I am still getting this error.

Please advise.

Thank you.

P.S.

This is what happens when I replace require() with import():

enter image description here

Tried other options, no luck

enter image description here

Some comments from StackOverflow:

image

@slishnevsky slishnevsky added the bug Something isn't working label Jan 31, 2024
@RyanLua
Copy link

RyanLua commented Mar 18, 2024

In #76 it mentions a fix. Basically got with versions 12+ will cause this error and running npm install got@'<12.0.0' which installs an older version of got fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants