JamesBroadberry / deno-bcrypt

A port of jBCrypt to TypeScript for use as a Deno module
ISC License
67 stars 5 forks source link

Error when importing #18

Closed ghost closed 3 years ago

ghost commented 3 years ago

When I tried to import the package, 3 errors appeared in my terminal:-

I used this line to import:- import * as bcrypt from "https://deno.land/x/bcrypt@v0.2.4/mod.ts";

My deno version: 1.9.0

I'm using Windows 10 as my operating system

error: TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'. Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'. { type: "module", deno: true },

    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:18:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:50:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'. Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'. { type: "module", deno: true },


    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:83:23

Found 3 errors.
[E] [daem] app crashed - waiting for file changes before starting ...
Ivan-Kouznetsov commented 3 years ago

Try running with --allow-net --unstable

JamesBroadberry commented 3 years ago

Hi @hazem-saeed

What @Ivan-Kouznetsov mentioned should fix your problem.

Thanks @Ivan-Kouznetsov for replying so quickly!

ghost commented 3 years ago

Thanks for replying so quickly, I was missing the --unstable flag while running deno. Thanks again.

CameronJYoung commented 3 years ago

Hello, I've been getting these same errors despite running deno with the --unstable and --allow-net flags. I've tried this on the latest deno and the same version mentioned above (1.9.0). I've also tried running this in a docker container and on my operating system and I get the same result every time.

error: TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:18:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:50:23

TS2345 [ERROR]: Argument of type '{ type: "module"; deno: boolean; }' is not assignable to parameter of type 'WorkerOptions'.
  Object literal may only specify known properties, and 'deno' does not exist in type 'WorkerOptions'.
    { type: "module", deno: true },
                      ~~~~~~~~~~
    at https://deno.land/x/bcrypt@v0.2.4/src/main.ts:83:23

Found 3 errors.

EDIT: @JamesBroadberry should I open a new issue for the above?

JamesBroadberry commented 3 years ago

@CameronJYoung Yes, please create a new issue if you think it's unrelated to this. It does look like the --unstable flag is missing though. However, if that didn't fix it for you, could you provide some way for me to replicate it please? (exact command ran and an example script that makes this happen?)

CameronJYoung commented 3 years ago

Apologies it was a stupid mistake. I wasn't using the unstable flag when caching the dependencies and then I had an issue where when I added it to my dockerfile it didn't update the container so I kept getting the error. Thanks for replying so fast!

sinux-l5d commented 2 years ago

Hey, I'm new to deno and I don't understand why bcrypt use unstable flag. Could you explain?

JamesBroadberry commented 2 years ago

Hi @Matows

It's because when this library was first written (and for compatibility with older versions of Deno), the only way to use the Crypto module for random number generation required by BCrypt while in a WebWorker requires the --unstable flag.

More details in this PR: https://github.com/denoland/deno/pull/5121

sinux-l5d commented 2 years ago

Thanks for the quick answer. Not a fan of unstable things, any alternative? Or is --unstable okay in deno?

JamesBroadberry commented 2 years ago

No problem. I'm not really sure.

There's currently a PR that I've not got around to reviewing yet that removes it with later version of Deno. I'll see if I can get around to it this weekend.

It's fine for now but I don't really like it either, it just allows unstable features and seems stable enough for this library.