pouchdb: Uncaught TypeError: PouchDB is not a constructor(…) using PouchDB 6.3.4

Issue

Getting error Uncaught TypeError: PouchDB is not a constructor(…) using PouchDB 6.3.4

bootstrap.js?5e63:21Uncaught TypeError: PouchDB is not a constructor
    at eval (eval at <anonymous> (http://192.168.42.204:8000/js/app.js:860:1), <anonymous>:21:13)
    at Object.<anonymous> (http://192.168.42.204:8000/js/app.js:860:1)
    at __webpack_require__ (http://192.168.42.204:8000/js/app.js:20:30)
    at eval (eval at <anonymous> (http://192.168.42.204:8000/js/app.js:1674:1), <anonymous>:8:1)
    at Object.<anonymous> (http://192.168.42.204:8000/js/app.js:1674:1)
    at __webpack_require__ (http://192.168.42.204:8000/js/app.js:20:30)
    at http://192.168.42.204:8000/js/app.js:64:18
    at http://192.168.42.204:8000/js/app.js:67:10

Info

  • Environment: (browser)
  • Platform: (Chrome/FireFox.)

Reproduce

Install pouchDB@6.3.4 using NPM and init PouchDB object

var PouchDB = require('pouchdb-browser');
window.db = new PouchDB('my_db');

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 20 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Had the same problem and solved it with this : const PouchDB = require('pouchdb').default;

Both import PouchDB from 'pouchdb' and what @madcorp206 said works. Using VueJS.

@PadaliaRushabh can you try import PouchDB from 'pouchdb-browser'?

I followed this instruction to use an older version of PouchDB and everything is now working as expected:

yarn add pouchdb-browser@6.2.0

Not sure what’s the real problem is though but hope this helps!

Both import PouchDB from 'pouchdb' and what @madcorp206 said works. Using VueJS.

this works for the newer version of node

const PouchDB = require('pouchdb').default;

Work for me too.

Had the same problem - using vue and pouchdb madcorp206 solution seemed to solve it: const PouchDB = require(‘pouchdb’).default;

Had the same problem and solved it with this : const PouchDB = require('pouchdb').default;

This did it for me…Thank yous!!!

Had the same problem - using vue and pouchdb madcorp206 solution seemed to solve it: const PouchDB = require(‘pouchdb’).default;

this works for me var PouchDB = require(‘pouchdb-browser’);

let pouchdb = PouchDB.default.defaults(); let db = new pouchdb(‘mydb’); db.info().then(info => console.log(info));

@ptitjes thank you, that worked! 😃