Running PouchDB within an Atom package


I’m getting the following error when trying to startup PouchDB 5.0.0 within an Atom package.

This is likely an Atom issue, as I understand Atom does not allow write permissions within a package. However, there is talk of PouchDB working within Atom on the discussion boards.

err {type: "OpenError", name: "OpenError", cause: Error: IO error: database/LOCK: No such file or directory at Error (native), message: "IO error: database/LOCK: No such file or directory"}

Simple code, taken from the PouchDB demo:

const PouchDB = require('pouchdb');

let db = new PouchDB('database');

function dbInit() {
  console.log('seeding db...');

  let todo = {
    _id: 'mydoc',
    title: 'test'
  db.put(todo).then(function(response) {
    // handle response
  }).catch(function(err) {

  db.get('mydoc').then(function(doc) {
  }).then(function(response) {
    // handle response
  }).catch(function(err) {


Storage limits with pouchDB and Electron

I’m not sure what this is intended to mean, but one of the major motivations for Atom is to allow reads and writes to the local file system.

The error message seems to indicate that it is attempting to open a file database/LOCK and is unable to because it does not exist. Perhaps the working directory where PouchDB is trying to create your database is one where you don’t have permissions?


Permissions don’t seem to be the problem. I’ve tried with the main directory permission as: drwxrwxrwx.

The error seems to be related to leveldown / levelup installation.

Uncaught (in promise) Error: leveldown not available (specify another backend using the 'db' option).

I’ve tried npm install leveldown within the pouchdb directory, as well as the electron installation method: HOME=~/.electron-gyp node-gyp rebuild --target=0.34.0 --arch=x64 --dist-url= within the leveldown directory. No luck.


The issue with LevelDOWN is that you need to recompile it for Atom. There is a tutorial here:

Also if you have trouble compiling it for various platforms, you can always use the IndexedDB or the WebSQL adapters instead (also described in the tutorial).


That’s true, you have to compile PouchDB for electron.

I finally figured the underlying issue out.

I was compiling from Typescript -> JS from a different directory. The database path wasn’t compiling properly in the build. Using an absolute path worked.

let db = new PouchDB(__dirname + '/db.json');