josephg / node-foundationdb

Modern Node.js FoundationDB bindings
Other
116 stars 17 forks source link

Error when using `require` instead of `import` #3

Closed eliot-akira closed 6 years ago

eliot-akira commented 6 years ago

The example code in README.md results in an error: fdb.openSync is not a function. This is because the following line:

const fdb = require('foundationdb')

..results in importing an object of the shape:

{
  default: {
    FDBError: [Function: FDBError],
    configNetwork: [Function: configNetwork],
    ...
  }
}

So I had to require the module like this:

const fdb = require('foundationdb').default

Related to: Microsoft/TypeScript#2719 - ES6 Modules default exports interop with CommonJS

josephg commented 6 years ago

Thanks for catching that. Fixed & republished.