pouchdb / pouchdb-auth

A PouchDB plug-in that simulates CouchDB's authentication daemon. Includes a users db that functions like CouchDB's.
36 stars 11 forks source link

TypeError: Promise.resolve is not a function on pouchdb-auth #45

Open semiautomatix opened 5 years ago

semiautomatix commented 5 years ago

Issue

I'm receiving the following error when using pouchdb-auth:

TypeError: Promise.resolve is not a function

PouchDB../node_modules/pouchdb-auth/lib/index.js.exports.useAsAuthenticationDB
/PWAProjects/pwa-tna/node_modules/pouchdb-auth/lib/index.js:63

  60 | }
  61 | 
  62 | 
> 63 | return utils.nodify(Promise.resolve().then(function () {
  64 |   // add wrappers and make system db
  65 |   if (!info.isOnlineAuthDB) {
  66 |     wrappers.installWrapperMethods(args.db, writeWrappers);

Info

Reproduce

My code is as below:

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

const db = new PouchDB(
    'http://localhost:5984/accord-tna',
    {
        skip_setup: true,
        auth: {
            username: 'admin',
            password: 'password',
        }
    }
  );
db.useAsAuthenticationDB();

As quick check does indeed reveal Promise.resolve to be undefined using the pouchdb-promise import.

95kach commented 5 years ago

+1

Hello, @marten-de-vries

The problem is here:

# lib/index.js
var Promise = require('pouchdb-promise');

We are getting { default: Promise };

Please replace it to require('pouchdb-promise').default;

OR update version to 7.0.0 in package.json: "pouchdb-promise": "^6.4.1",