1

I'm new to TypeScript and Ionic2 and tried to use LokiJS on a first app.

So far I created a new app as suggested on Ionic2 doc:

npm install -g ionic cordova typings
ionic start cutePuppyPics --v2
cd cutePuppyPics

After that I installed loki and used typings to integrate it:

npm install lokijs
typings install dt~lokijs --global --save

Then I edited one of the given pages of the tab panel: pages/home/home.ts

import { Component } from '@angular/core';

import { NavController } from 'ionic-angular';

import * as lokijs from "lokijs";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
    if(!!lokijs)
      console.log("loki there");
      else console.log("no loki :(");
  }
}

Bundling app works fine, but on the console I get an error:

Uncaught ReferenceError: fs is not defined(…)

Is this a error on the typings definition?

What am I missing? How to properly import lokijs to Ionic2?

kerosene
  • 930
  • 14
  • 31

0 Answers0