0

I need to import NeDB and I need to do this using ES Module, what I need from NeDB is DataStore.

When I try to import DataStore using the usual synthax :

import { DataStore } from 'nedb';

I have this error :

Named export 'Datastore' not found. The requested module 'nedb' is a CommonJS module,
which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export

I tried :

import * as nedb from 'nedb';
console.log(nedb)
// Output
// [Function: Datastore]

I also tried :

import nedb from 'nedb';
const { DataStore } = nedb;
console.log(DataStore);
// Output
// undefined

But how can I access Datastore ?

Thx,
Maxime

nem0z
  • 1,060
  • 1
  • 4
  • 17

1 Answers1

0

I finnaly foud the solution :

import DataStore from 'nedb';
// Then I can use :
new DataStore(...); // works

I don't know how I missed it... Thx everyone

nem0z
  • 1,060
  • 1
  • 4
  • 17