Discussion:
[nodejs] Uncaught TypeError: PouchDB is not a constructor
Matias Salimbene
2018-10-19 00:38:33 UTC
Permalink
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.
--
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+***@googlegroups.com.
To post to this group, send email to ***@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.
Joshua Holbrook
2018-10-23 20:14:00 UTC
Permalink
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
Post by Matias Salimbene
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*
var PouchDB = require("pouchdb");var db = new PouchDB("scr");
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.
--
Job board: http://jobs.nodejs.org/
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/ba0ec025-ed76-491c-8e25-559051d07c3f%40googlegroups.com
<https://groups.google.com/d/msgid/nodejs/ba0ec025-ed76-491c-8e25-559051d07c3f%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAHL2YmphKJOffZG1gK3fT6%3DrSnscF-Ep3dpTgxkCZ0ssrtBqCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Krystle Lopez
2018-10-30 10:38:00 UTC
Permalink
Post by Matias Salimbene
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*
var PouchDB = require("pouchdb");var db = new PouchDB("scr");
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.
--
Job board: http://jobs.nodejs.org/
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/ba0ec025-ed76-491c-8e25-559051d07c3f%40googlegroups.com
<https://groups.google.com/d/msgid/nodejs/ba0ec025-ed76-491c-8e25-559051d07c3f%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CADBCV7s57aoRJn-mzmV_o5a53RH06nGPazzazzj9En-j1pS6tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...