chatgpt-api: Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.

node-fetch v3 can’t use require(), can downgrade to v2.6.7

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to fix this in typescript(express js) by installing tsx in devDependencies and changing my scripts to “scripts”: { “dev”: “tsx watch src/index.ts”, “build”: “tsc”, “start”: “tsx dist/index.js” } and installing node >= 18

@transitive-bullshit I successfully modified chatgpt-api to support cjs, wait I will open a pull request!

Please use v1.3.0 which includes support for CommonJS via #19.

Thanks @GoneTone 🙏

If you run into an issue with v1.3.0 and commonjs, please open a separate issue to discuss and provide as many details about your environment as possible — including a minimal reproduction if possible.

it is like ES module dictatorship.

is it possible to use it with regular require?

I’m using it in my Discord bot, project using require()…