简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM