key-encoder-js icon indicating copy to clipboard operation
key-encoder-js copied to clipboard

TypeError: KeyEncoder is not a constructor

Open xird opened this issue 5 years ago • 1 comments

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:

  • In a new directory, npm init
  • npm i key-encoder
  • In index.js, add just the two lines from the README:
var KeyEncoder = require('key-encoder'),
    keyEncoder = new KeyEncoder('secp256k1')
  • run "node index.js"

Result:

    keyEncoder = new KeyEncoder('secp256k1')
                 ^

TypeError: KeyEncoder is not a constructor

Expected result: No output.

xird avatar Mar 03 '20 10:03 xird

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

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

friedger avatar Mar 03 '20 13:03 friedger