Open slishnevsky opened 5 months ago
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():
Tried other options, no luck
Some comments from StackOverflow:
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.
npm install got@'<12.0.0'
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():
Tried other options, no luck
Some comments from StackOverflow: