transitive-bullshit / bing-chat

Node.js client for Bing's new AI-powered search. It's like ChatGPT on steroids 🔥
MIT License
1.22k stars 128 forks source link

Module '"node:crypto"' has no default export #13

Open hajsf opened 1 year ago

hajsf commented 1 year ago

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
Erisfiregamer1 commented 1 year ago

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. :)

transitive-bullshit commented 1 year ago

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.

Erisfiregamer1 commented 1 year ago

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.

Oh. Whoops. I assumed Deno since it uses that exact same syntax for importing it's Node polyfills.

Roosteridk commented 1 year ago

Speaking of Deno, were you able to get this package working with Deno? I keep getting WebSocket error: Error: Unexpected server response: 400

Erisfiregamer1 commented 1 year ago

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.