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
- Merge pull request #11 from RealTong/main fix: 🐛 修复bot回复用户时用户名替换失败的问题 — committed to cyhhao/chatgpt-api by fuergaosi233 2 years ago
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-apito support cjs, wait I will open a pull request!Please use
v1.3.0which includes support for CommonJS via #19.Thanks @GoneTone 🙏
If you run into an issue with
v1.3.0and 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()…