I'm trying to import PouchDB into my Angular application. I've tested differents import methods :
import PouchDB from 'pouchdb';
import * as PouchDB from 'pouchdb';
I am using it like below into a service :
database: PouchDB.Database = new PouchDB(DATABASE_URL);
If I do : import PouchDB from 'pouchdb', I get the following error message :
src/app/core/pouchdb/pouchdb.service.ts(3,8): error TS1192: Module '"{PATH_OF_PROJECT}/node_modules/@types/pouchdb/index"' has no default export.
If I do : import * as PouchDB from 'pouchdb', I get the following error message :
ERROR TypeError: PouchDB is not a constructor at new PouchDBService
Here are the versions of the different packages :
Thank you in advance for your answers.
Add "allowSyntheticDefaultImports": true in the compilerOptions section of your tsconfig.json
and use
import PouchDB from 'pouchdb';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With