bing-chat
bing-chat copied to clipboard
Module '"node:crypto"' has no default export
I got the below error while trying to test it at WSL 2 (Ubuntu under Windows), thanks
$ ls
demos docs license main.js media node_modules package-lock.json package.json pnpm-lock.yaml readme.md src tsconfig.json tsup.config.ts typedoc.json
$ cd demos
$ ls
demo-conversation.ts demo-on-progress.ts demo.ts
$ npx tsc demo-conversation.ts
../src/bing-chat.ts:1:8 - error TS1192: Module '"node:crypto"' has no default export.
1 import crypto from 'node:crypto'
~~~~~~
../src/bing-chat.ts:3:8 - error TS1259: Module '"/home/hajsf/bing-chat/node_modules/@types/ws/index"' can only be default-imported using the 'esModuleInterop' flag
3 import WebSocket from 'ws'
~~~~~~~~~
../node_modules/@types/ws/index.d.ts:398:1
398 export = WebSocket;
~~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
Found 2 errors in the same file, starting at: ../src/bing-chat.ts:1
You're supposed to run this using Deno. "node:crypto" is Deno syntax for the built-in crypto module.
Deno removes the need to compile Typescript. It's way better, trust me. :)
You're supposed to run this using Deno. "node:crypto" is Deno syntax for the built-in crypto module.
Deno removes the need to compile Typescript. It's way better, trust me. :)
No; node:crypto is the new standard way of defining imports in Node.js. Deno may support this too (I haven't tested), but this package is meant to be used from Node.js 16+.
@hajsf it looks like a problem with your environment, possibly node.js version, TS version, build chain, etc. Not sure.
You're supposed to run this using Deno. "node:crypto" is Deno syntax for the built-in crypto module. Deno removes the need to compile Typescript. It's way better, trust me. :)
No;
node:cryptois the new standard way of defining imports in Node.js. Deno may support this too (I haven't tested), but this package is meant to be used from Node.js 16+.@hajsf it looks like a problem with your environment, possibly node.js version, TS version, build chain, etc. Not sure.
Oh. Whoops. I assumed Deno since it uses that exact same syntax for importing it's Node polyfills.
Speaking of Deno, were you able to get this package working with Deno? I keep getting WebSocket error: Error: Unexpected server response: 400
Speaking of Deno, were you able to get this package working with Deno? I keep getting
WebSocket error: Error: Unexpected server response: 400
Bad request. You're probably doing something wrong.