Node fs Error: EPERM: operation not permitted, open
Solution 1
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.
Solution 2
If you have the file that you can't open or modify mounted as a volume in docker restarting docker should fix the issue.
Solution 3
On my Windows 10 machine, I encountered this error when running an old Node JS project. I think Node version 10.16.
In any case, it was trying to modify a dotfile in my project. Be sure that the file isn't hidden on Windows. After unchecking the hidden option in the file properties pop up. Everything worked.
So to fix:
- Right click file in Windows Explorer
- Select properties
- Uncheck Hidden
- Click Ok
- Re-run your command.
Solution 4
i had to run the node command prompt as administrator and that fixed the issue.
Solution 5
I face this issue when I was deleting a file/folder.
Solution:
Just restart your code editor/ terminal Or Restart your computer
Sergiu
Updated on October 05, 2021Comments
-
Sergiu over 2 years
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?