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

CJS Incompatibity Error #620

Open
2 tasks done
darksuei opened this issue Oct 18, 2023 · 1 comment
Open
2 tasks done

CJS Incompatibity Error #620

darksuei opened this issue Oct 18, 2023 · 1 comment

Comments

@darksuei
Copy link

darksuei commented Oct 18, 2023

Verify latest release

  • I verified that the issue exists in the latest chatgpt release

Verify webapp is working

  • I verify that the ChatGPT webapp is working properly for this account.

Environment details

NodeJS v18.17.0
Ubuntu 22.04

Describe the Bug

Steps to Reproduce :
import { ChatGPTUnofficialProxyAPI } from "chatgpt";
const api = new ChatGPTUnofficialProxyAPI({
accessToken: "xxx",
apiReverseProxyUrl: "yyy",
});

Importing the module does not work in typescript backend, it seems to stem from some incompatibility the module has with cjs that typescript compiler spits out. Is there a way to go about this without reconfiguring the ts config? PS even that doesnt work.

Error: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/bot/Desktop/Projects/Mains/studera-be/node_modules/chatgpt/build/index.js from /home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts not supported.
Instead change the require of index.js in /home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts to a dynamic import() which is available in all CommonJS modules.
at require.extensions. [as .js] (/home/bot/Desktop/Projects/Mains/studera-be/node_modules/ts-node/dist/index.js:851:20)
at Object. (/home/bot/Desktop/Projects/Mains/studera-be/utils/utils.ts:13:19)
at m._compile (/home/bot/Desktop/Projects/Mains/studera-be/node_modules/ts-node/dist/index.js:857:29)
...

@swellee
Copy link

swellee commented Jan 26, 2024

I run into the same error. is it resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants