Uncaught TypeError: PouchDB is not a constructor

160 views
Skip to first unread message

Matias Salimbene

unread,
Oct 23, 2018, 3:57:33 PM10/23/18
to nodejs
Hello,

I'm using pouchDB as a cdb for an app and I'm struggling to understand this error: Uncaught TypeError: PouchDB is not a constructor
The declaration is as follows:
var PouchDB = require("pouchdb");
var db = new PouchDB("scr");
I've read about how it may be related to types and that adding:
 "@types/node": "^10.12.0",
 "@types/pouchdb": "^6.3.2",

to my package.json should help, but it isn't. I've tested on another simple .js file and works, but on my main app it isn't. Still, I don't understand why it wouldn't work. The pouch documentation is quite clear https://pouchdb.com/api.html#create_document. I should mention I'm running this on the context of an electron app, not in the browser.

Any tip is greatly appreciated,

Cheers, Matias.

Joshua Holbrook

unread,
Oct 23, 2018, 4:14:54 PM10/23/18
to nod...@googlegroups.com
A tiny hint maybe: it looks like pouchdb uses es6 module syntax https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb/src/pouchdb.js and this is presumably compiled via babel - so the way that require works might be funky. Dunno though. Either way, I'd see if PouchDB here is actually an object with, say a "default" property whose value is the PouchDB constructor. console.log will probably help you here.

Good luck!

--Josh

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/ba0ec025-ed76-491c-8e25-559051d07c3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Krystle Lopez

unread,
Nov 1, 2018, 2:07:41 AM11/1/18
to nod...@googlegroups.com
--
Reply all
Reply to author
Forward
0 new messages