Skip to content

randombytes esModuleInterop import flag error #174

@rvdende

Description

@rvdende

Hi

In a new typescript project when using bitbox-sdk by npm i bitbox-sdk:

import { BITBOX } from 'bitbox-sdk'
let bitbox = new BITBOX();
bitbox.Mnemonic.generate()

When using tsc to compile the typescript it reports these errors:

C:\Users\rouan\Desktop\work\tempbitbox>tsc test.ts
node_modules/bitbox-sdk/lib/Crypto.ts:1:8 - error TS1259: Module '"C:/Users/rouan/Desktop/work/tempbitbox/node_modules/@types/randombytes/index"' can only be default-imported using the 'esModuleInterop' flag

1 import randomBytes from "randombytes"
         ~~~~~~~~~~~

  node_modules/@types/randombytes/index.d.ts:10:1
    10 export = randomBytes;
       ~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/bitbox-sdk/lib/Mnemonic.ts:5:8 - error TS1259: Module '"C:/Users/rouan/Desktop/work/tempbitbox/node_modules/@types/randombytes/index"' can only be default-imported using the 'esModuleInterop' flag

5 import randomBytes from "randombytes"
         ~~~~~~~~~~~

  node_modules/@types/randombytes/index.d.ts:10:1
    10 export = randomBytes;
       ~~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


Found 2 errors.

This leads me to believe that we need to change code in bitbox-sdk or the randombytes module? Anyone that can provide input on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypescriptRequires expertise in TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions