Can't use PouchDB with Ionic 2 RC1

I follow this tutorial but i get require is not defined error in Chrome. I read that topic but i can’t get anywhere… The tutorial with Ionic Beta is working as expected but RC1 fails. Does it have to be sooo difficult to get each step in Ionic2? Is there a tutorial/clue to make a simple connection with PouchDB?


I installed latest Ionic App Scripts build tools (which uses Webpack instead of Rollup) with this command:

npm install @ionic/app-scripts@beta

Then run npm run build to test the new build process. Source topic

And then imported PouchDB like this:

import * as PouchDB from 'pouchdb'; // no need to use require() anymore :slight_smile:

Then tried this in a simple class:

  private _db;
  private _record;
  ionViewDidLoad() { // WARNING: tutorial uses old "ionViewLoaded" which is not working anymore
    console.log('starting db');
    this._db = new PouchDB('birthday2');
    this._record = { name: 'emre' };;
    console.log("record ok");

And voila! Hope this helps someone :slight_smile:

Note: I’ve also added typings of PouchDB, i’m not sure if it was necessary:

typings install --global --save dt~pouchdb dt~pouchdb-adapter-websql dt~pouchdb-browser dt~pouchdb-core dt~pouchdb-http dt~pouchdb-mapreduce dt~pouchdb-node dt~pouchdb-replication