Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

db.crypto is not a function ('undefined')

See original GitHub issue

Trying to run this in the browser. And I’m at a loss.

var db = PouchDB('dudes'); db.crypt('password').then(console.log(db))


Uncaught TypeError: db.crypt is not a function at <anonymous>:2:6 at Object.InjectedScript._evaluateOn (<anonymous>:875:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:808:34) at Object.InjectedScript.evaluate (<anonymous>:664:21)(anonymous function) @ VM33737:2InjectedScript._evaluateOn @ VM33252:875InjectedScript._evaluateAndWrap @ VM33252:808InjectedScript.evaluate @ VM33252:664

Umm… File loaded? Yup.

cryto: {
_subtle: {
  decrypt() {...}
  encrypt() {...}

Oh cool.

function myEncrypt(x) {
Uncaught (in promise) TypeError: Failed to execute 'encrypt' on 'SubtleCrypto': 3 arguments required, but only 1 present.
    at TypeError (native)
    at myEncrypt (<anonymous>:3:17)
    at <anonymous>:2:1
    at Object.InjectedScript._evaluateOn (<anonymous>:875:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:808:34)
    at Object.InjectedScript.evaluate (<anonymous>:664:21)

Umm, huh?

encrypt() { [native code] }

I’m sooooo lost. I’m guessing native code is crap from V8, since it looks like this is running VM’s. Am I right? Honestly, I really need more documentation than add this browserified file like normal.

I tried looking through the source code but then my brain overheated.

Do I need to also download the browseried version of crypto-browserify?

Is it even worth pursuing this? You haven’t checked-in for 5 months…

Thanks for your hard work.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

erik127commented, May 19, 2016

@paynoattn I had a similar issue. I just noticed that Nolan uses another script in his example than the one mentioned in… So instead of using the one linked from the readme page: I tried this one:

That solved my issue.

calvinmetcalfcommented, Jan 14, 2016

if you are using browserify or some other bundler you should need to add:

var PouchDB = require('pouchdb');
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: db.collection is not a function, CANNOT GET
Ok, in your methods of database.js you pass db variable, but this is not of db instance, it is mongoose model, and you...
Read more >
undefined is not an object (evaluating 'db.crypto(password ...
Using PouchDb and CryptoPouch in an Ionic 2 app fails when trying to encrypt a database. I have created this project to demonstrate...
Read more >
How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >
Error: db.collection is not a function : r/Firebase - Reddit
Hi. I'm new to Firebase and was trying to create a blogging project. I'm using client-side JS and I'm trying to integrate the...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
For example, a request from Node.js to the database engine to fetch some ... However, in JavaScript, with callbacks a particular function may...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found