Node fs Error: EPERM: operation not permitted, open

Sergiu picture Sergiu · Oct 29, 2015 · Viewed 42k times · Source

I get this error in my app:

Error: EPERM: operation not permitted, open 'C:\Program Files (x86)\Full Menu\db\main.json'

The app I have is built with electron-boilerplate. I am using this function to get the path to the root of the app:

path.dirname(process.execPath)

And this is the script that writes the file:

fs.writeFile(apath + '/db/' + elem + '.json', JSON.stringify(results)

I know what the problem is: permissions. But how could I get this working without running the app as an administrator?

Answer

HockeyJ picture HockeyJ · Mar 17, 2017

For the benefit of searchers; I has this error. I added full permissions for Everyone as a test, but that didn't fix it. The issue was that the file was set to readonly (by source control).

Unchecking the readonly option in the file properties fixed the issue.