So I created a small electronJs desktop application, and for the data storage I used nedb. In dev mode, it works perfectly fine, but when I compile in production (I’m on mac), I can’t write the database file anymore.
Here is the code I use to declare my database and create my file if it doesn’t exist already :
var Datastore = require('nedb') , db = new Datastore({ filename: 'datafile.db', autoload: true });
So in dev mode, the file is created and everything is okay. But after compiling, my app doesn’t create my “datafile.db”
Someone can help ?
Thank you !
Answer
In dev mode the file is where you expect it to be, but most likely, your production code is running from a different file location. So…
This will likely be a path problem. Try to create absolute paths everywhere to ease this pain. You can use node __dirname
to help with this.