bing-chat icon indicating copy to clipboard operation
bing-chat copied to clipboard

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

Open hajsf opened this issue 2 years ago • 5 comments
trafficstars

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

hajsf avatar Mar 06 '23 05:03 hajsf

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

eris-webserv avatar Apr 07 '23 02:04 eris-webserv

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.

transitive-bullshit avatar Apr 07 '23 02:04 transitive-bullshit

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.

eris-webserv avatar Apr 07 '23 23:04 eris-webserv

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

Roosteridk avatar Apr 08 '23 14:04 Roosteridk

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.

eris-webserv avatar Apr 08 '23 15:04 eris-webserv