EPERM: operation not permitted, rename


Hi everyone,

I’m facing a strange bug in Electron: I’m using NEDB as database for my app, and the file is stored in %AppData%\roaming\museeks\library.db.

When I run electron with the command line in Git Bash ./electron.exe, everything works like a charm, but when I run electron by double-clicking on electron.exe, I get this error: Uncaught Error: EPERM: operation not permitted, rename 'C:\[...]\AppData\Roaming\museeks\library.db~' -> 'C:\[...]\AppData\Roaming\museeks\library.db

I just have no idea what is going on, when this happens, it seems like there’s a process running, and I can’t delete library.db fily anymore.

It may be due to the the fact the file is not closed ? or in use somewhere ? but where ?

I didn’t want to open an issue for that, so you might be able to help me with that, thanks in advance


It sounds like you’re running into a very similar issue as this one:


The very strange thing is everything was working great like 5 days ago. If I take an older version of my app, with older version of Electron and older versions of my app packages, and I still get the error.

The only new thing I remember is a Windows update, but this shoudn’t be that


Could it be that something changed the permissions on the library.db file?


Permissions seem ok.

But I’m definetly lost. I added

fs.writeFile(path.join(pathConfig, 'test'), "Hey there!", function(err) {
    if(err) {
        return console.log(err);

    console.log("The file was saved!");

to the file where I call the db, just to check if I could write in the folder, and by adding this piece of code, no error, I’m just adding a file. So I’m a bit like “wtf did happen”.


Ok, I may open an issue for that, I’ll do more testing first, It seems more related to electron than NeDB, but so far, this is definetly the weirdest bug I’ve ever seen.

var db = new nedb({
    filename: path.join(pathConfig, 'library.db'),
    autoload: true

db.reset = function() {
    db.remove({}, { multi: true }, function (err, numRemoved) {
        db.loadDatabase(function (err) {
            if(err) throw err;

 // Without the line below, db.loadDatabase throw 'Error: EPERM: operation not permitted, rename 'C:\[...]\AppData\Roaming\museeks\library.db~' -> 'C:\[...]\AppData\Roaming\museeks\library.db'
fs.writeFile(path.join(pathConfig, '.init'), "", (err) => { if(err) return err; });


Meanwhile, you may try yo re-install your app to a partitition different from C:
I try it and it worked !


I have same issue please help me i tried re-install but not working



The issue was my DB was too big (it was 400 or 500MB at the time, NeDB is not meant to handle that amount of information).

I had to switch to LinvoDB3.


My DB is small. But I’m still getting the same error. Am I doing something wrong?