3

I'm also trying to follow the Tutorial How To Use PouchDB + SQLite For Local Storage In Ionic 2, which seems a good entry point for using pouchdb with Angular 2 / Ionic 2. My OS is OSx

After getting able to install typings 'require' ionic serve throws:

TypeScript error: (...) Error TS2304: Cannot find name 'require'.

I followed the installing typings require failed in macOSX and Install Typings require for Ionic2 application threads but it didn't help me. (beside of a better understanding of 'TypeScript')

the require files are under:

/ionic2-tutorial-pouchdb/typings/globals/require

any Ideas? The tutorial about 'install require' doesn't work for me.

thx Pitt

Community
  • 1
  • 1
pdewaard
  • 123
  • 6

1 Answers1

0

I'm guessing that you have a line of code like:

let PouchDB = require('pouchdb');

You do not need to use require for importing into Angular2. Instead you should use import like this:

import PouchDB from 'pouchdb';

Reference from one of the GitHub issues on the PouchDB GitHub account

The link you provided also uses import rather than require. Also in newer versions of typescript, Typings have been replaced with @Types.

Marc Evans
  • 27
  • 2