Issue with packaging app using asar


#1

Does the asar packaging prevent the use of fs.writeFile() even if the filepath is outside the app.asar?

For example inside browser code I could have a simple:

fs.writeFile(’…/app_data/test_file.txt’, ‘Hello’, function(err){});

It doesn’t seem to be writing this file when the app is packaged into the app.asar file. Any ideas how I can get past this issue?

Thank you!!!


#2

To my knowledge, the asar packaging doesn’t modify the fs module at all. I would start by using an absolute path to see if that might be part of the problem.


#3

Using the entire path works, but I need a way to reference that path from a file inside the app.asar.

So /browser/module.js has a writeFile pointing to that app_data directory under /Resources, so is there a recommended way to get that path without using the entire /Users/johndoe/Documents/Electron/Electron.app/Contents/Resources/app_data path?

Thanks leedohm!