Using pouchdb-adapter-memory plugin in vue3

78 Views Asked by At

I am trying to start a local PouchDB database with a memory adapter mode using the package pouchdb-adapter-memory on a vue3 project. After installing the package, I am getting this error: Uncaught TypeError: inherits3 is not a function

When starting the vue app without the package and running PouchDB normally it dose work. Also, when trying to run PouchDB on a local server (not on the frontend) in memory mode, it dose work.

Here is an example of the usage of the package:

import PouchDB from 'pouchdb';
import PouchDBFind from 'pouchdb-find';
import PouchdbAdapterMemory from 'pouchdb-adapter-memory';

PouchDB.plugin(PouchDBFind);
PouchDB.plugin(PouchdbAdapterMemory);

class LocalDBClass {
    private localDB: PouchDB.Database;

    public async init(dbName: string){
        this.localDB = new PouchDB(dbName, { adapter: 'memory' });
    }
}

Here is a list of steps I was trying to use in order to solve the issue:

  1. I was trying to delete the node_modules directory and reinstall the packages using npm i.
  2. I was trying to look for other ways to implement it, but all of the other solutions are using the package pouchdb-adapter-memory in one way or another.
  3. I was trying to implement this solution with no success.
  4. I was trying to achieve my goal by using the package pouchdb-memory with no success.
  5. The only way I did make it work, was by import it in the index.html (see the block of code below). It is not a good solution, because I am consuming PouchDB from an external package that I've created.
<html>
 <head>
   <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pouchdb.js"></script>
   <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pouchdb.memory.min.js"></script>
 </head>
...
0

There are 0 best solutions below