Closed wsdo closed 1 year ago
From the readme:
async function example() {
// To use ESM in CommonJS, you can use a dynamic import
const { ChatGPTAPI } = await import('chatgpt')
const api = new ChatGPTAPI({
sessionToken: process.env.SESSION_TOKEN
})
await api.ensureAuth()
const response = await api.sendMessage('Hello World!')
console.log(response)
}
(This project does not support a commonjs export because it is deprecated for all intents and purposes and is a pain for maintainers to support.)
It doesn't work in nestjs framework. It still emit error "const { ChatGPTAPI } = await Promise.resolve().then(() => __importStar(require('chatgpt')));"
@h-gyeom other people have posted the same thing and gotten it to work with nestjs. Please search the github issues.
I created a starter repository for NestJS + ChatGPT: https://github.com/mitkodkn/nestjs-chatgpt-starter
Hope it helps.
use nestjs
const chatgpt_1 = require("chatgpt"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module