Skip to content

Commit 57a1d6e

Browse files
authored
fix: ESM error (#826)
1 parent 9081b22 commit 57a1d6e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"scripts": {
1717
"start": "esno ./src/index.ts",
1818
"dev": "esno watch ./src/index.ts",
19-
"prod": "esno ./build/index.js",
19+
"prod": "node ./build/index.mjs",
2020
"build": "pnpm clean && tsup",
2121
"clean": "rimraf build",
2222
"lint": "eslint .",

service/src/chatgpt/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import 'isomorphic-fetch'
33
import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt'
44
import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt'
55
import { SocksProxyAgent } from 'socks-proxy-agent'
6-
import { HttpsProxyAgent } from 'https-proxy-agent'
6+
import httpsProxyAgent from 'https-proxy-agent'
77
import fetch from 'node-fetch'
88
import axios from 'axios'
99
import { sendResponse } from '../utils'
1010
import { isNotEmptyString } from '../utils/is'
1111
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
1212
import type { RequestOptions } from './types'
1313

14+
const { HttpsProxyAgent } = httpsProxyAgent
15+
1416
dotenv.config()
1517

1618
const ErrorCodeMessage: Record<string, string> = {

service/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineConfig({
44
entry: ['src/index.ts'],
55
outDir: 'build',
66
target: 'es2020',
7-
format: ['cjs'],
7+
format: ['esm'],
88
splitting: false,
99
sourcemap: true,
1010
minify: false,

0 commit comments

Comments
 (0)