How do I import lokijs in aurelia

377 Views Asked by At

I recently installed and imported lokijs in aurelia with jspm :

install:

jspm  install npm:lokijs

import:

import * as loki from 'lokijs'

the problem is when I want to create a db instance using loki, I get an error saying that 'loki is not a constructor'.

var db = new loki('loki.json')

error : > Message: loki is not a constructor

1

There are 1 best solutions below

1
On BEST ANSWER

The library actually is not written with ES6 syntax. Simply import it as:

import loki from 'lokijs';

You can then use it like you have written in your question:

var db = new loki('loki.json');