Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hajsf opened this issue Mar 6, 2023 · 5 comments
Open

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

hajsf opened this issue Mar 6, 2023 · 5 comments

Comments

@hajsf
Copy link

hajsf commented Mar 6, 2023

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
Copy link

Erisfiregamer1 commented Apr 7, 2023

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
Copy link
Owner

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
Copy link

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
Copy link

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

@Erisfiregamer1
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants