Cannot create/access nedb with packaged app


This last week I decided that nedb was a good solution for me with my app, and so I’ve gone ahead and used that as my database driver. Everything works perfectly locally, and I’ve set up ipc channels to handle database inserts and querying etc so that electron can talk to Angular etc.

Today I decided to give packaging a go, to make sure that my app functions properly when running as an actual OS X app. Everything seems to have packaged fine, and I can run my app which loads up just fine. The only issue being that I suspect the database file is not created and/or read from during runtime. I’ve put a test_data.js file in my application which should be called by the renderer process to populate a database file ‘app.db’ with data ready for my app to be tested on startup.

Are there any requirements with nedb and packaging an app to ensure that the file can be created/read from properly? I feel like I’m missing a trick here!


I encountered a similar problem. My NeDB datastore was in my static assets folder so that it would be embedded in the app asar archive after packaging. Problem is, one can read from an asar file but not write, and NeDB needs either to write to the disk or to run in memory. I’ve solved this asar limitation by opting for an in memory database which is populated at startup from a json file stored in the asar archive as I don’t have a need to store changes to my data. Otherwise, you might consider leveraging userdata path to write your datastore to.