Search code examples
javascriptwebpackbrowserpouchdb

Uncaught TypeError: PouchDB.plugin is not a function


When i execute the code belove, this error shows up: Uncaught TypeError: PouchDB.plugin is not a function. If i install the pouchdb package from npm and change the first line accordingly, then the plugin part works but if i want to use a function from pouchdb-authentication i getting a function not found error.

const PouchDB = require('pouchdb-browser');

let auth = require('pouchdb-authentication');

PouchDB.plugin(auth);

The code should execute without errors and the functions from the authentication plugin should work.


Solution

  • I fixed it with replacing the code this way:

    import PouchDB from 'pouchdb';
    import auth from 'pouchdb-authentication';
    PouchDB.plugin(auth);
    

    Now it works without problems