aurelialokijs

How do I import lokijs in aurelia


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


Solution

  • 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');