stacks-network / key-encoder-js

Library for encoding and decoding ecdsa private keys and converting between formats
MIT License
44 stars 27 forks source link

TypeError: KeyEncoder is not a constructor #16

Open xird opened 4 years ago

xird commented 4 years ago

I'm trying to use the library, but can't even get started due to an error: "TypeError: KeyEncoder is not a constructor"

To reproduce:

var KeyEncoder = require('key-encoder'),
    keyEncoder = new KeyEncoder('secp256k1')

Result:

    keyEncoder = new KeyEncoder('secp256k1')
                 ^

TypeError: KeyEncoder is not a constructor

Expected result: No output.

friedger commented 4 years ago

You should add .default with the required call, like this:

var KeyEncoder = require('key-encoder').default