Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get permissions to create a file/directory with node fs

When running the following in my packaged electron app:

fs.mkdirSync('myNewDirectory');

I keep getting EACCES: permission denied, mkdir.

This doesn't happen when I'm in dev mode. It only happens after I package and run the app.

How do I get the appropriate permissions to create a directory, or even a file, in a packaged electron app?

like image 578
dmoss18 Avatar asked Dec 24 '22 12:12

dmoss18


1 Answers

mkdirSync will attempt to create myNewDirectory relative to the current working directory. Try setting the absolute path, perhaps using __dirname.

like image 193
weiyin Avatar answered Dec 28 '22 11:12

weiyin