I am trying to use pouchdb with Typescript. I cannot link to the pouchdb module.
import { PouchDB } from "pouchdb"
reports that it cannot find module pouchdb, even though it is in node_modules.
I also cannot find the appropriate typings for pouchdb.
Install PouchDB Server Execute the following code on Node. js command prompt to install PouchDB: npm install -g pouchdb-server.
PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser. PouchDB was created to help web developers build applications that work as well offline as they do online.
It stores data locally using IndexedDB and WebSQL in the browser. You can also communicate with remote and local databases continuously using PouchDB without noticing any difference. It is available on GitHub and on other open source application.
I'm doing this in Ionic, so I may be missing a step on getting the types file loaded properly.
Make sure your types are installed with:
npm install --save-dev @types/pouchdb
At the top of your data service import pouch like so:
import * as PouchDB from 'pouchdb';
* edit *
I don't have all the facts, but this is my current understanding. Typings is no longer needed in Typescript >2.0 I believe typescript now works automatically with types files installed from DefinitelyTyped. DefinitelyTyped is an official central repository that is kept current like npm. And even if I'm dead wrong about all this, DefinitelyTyped is still better than typings and has a much bigger community.
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