14

Tried using these imports

import PouchDB from 'pouchdb';
import PouchDBAuth from 'pouchdb-authentication';

PouchDB.plugin(PouchDBAuth)

Module ''pouchdb-authentication'' has no default export is the error generated while using these imports.

PouchDB.plugin(require('pouchdb-authentication'));

Using require is removing the error but still showing db.login() is not a function. Can anyone suggest where the issue is?

Ramesh R
  • 7,009
  • 4
  • 25
  • 38
shalini
  • 171
  • 1
  • 8
  • maybe check the version of you plugin. your code should work; pouchdb-authentication definitely have a default export. and maybe do npm i again – Femi Oni Jan 26 '18 at 19:37
  • Same here, I can output pouchdb-authentication which has the login function but this line does not affect the Pouchdb object : PouchDB.plugin(PouchDBAuth), so the db.login is undefined – Ostn Aug 07 '18 at 15:10

2 Answers2

3

Well I found why it was not working in my situation, I was using this :

import '*' as PouchDBAuthentication from 'pouchdb-authentication';

instead of

import PouchDBAuthentication from 'pouchdb-authentication';

So the right way is

import PouchDBAuthentication from 'pouchdb-authentication';
import PouchDB from 'pouchdb';

PouchDB.plugin(PouchDBAuthentication);

In the second hand the following steps should be done : https://github.com/pouchdb-community/pouchdb-authentication/issues/211

Ostn
  • 803
  • 1
  • 9
  • 27
0

No Need Below Library

import PouchAuth from 'pouchdb-authentication';

just pass auth PouchDb

new PouchDB('url', {
  auth: {
    username: 'user',
    password: 'pass'
  }
}
Balaji
  • 9,657
  • 5
  • 47
  • 47