Well, this bug will only occur on MacOS, since server use ${__dirname}/storage/ as a folder to save user data, however on mac you cannot write that read-only folder (which will be actually /private/blablabla/Console Lite.app/path/to/your/script).
As I have figured out, maybe you should use something like fs.mkdir(app.getPath('userData') + '/storage') and fs.mkdir(app.getPath('userData') + '/storage/main.db'), etc. to avoid raising IO Error: No such file or directory, and handle the err argument of the callback function correctly since the err might told you that the directory already exists (which shouldn't be handled as an error).
That would be similar in ipcMain.on('doImport', ...) and setupExportHandler(...).
By the way:
sudo cannot fix this issue
move app to /Application instead of just start it in any folder cannot fix this
this bug can be recognized by users: alert("已经有一个Console Lite在运行") (or something like that)
Well, this bug will only occur on MacOS, since
server
use${__dirname}/storage/
as a folder to save user data, however on mac you cannot write that read-only folder (which will be actually/private/blablabla/Console Lite.app/path/to/your/script
).in this answer https://stackoverflow.com/questions/38067298/saving-files-locally-with-electron it is said that developers could use
app.getPath('userData')
(in most cases that will be${process.env.HOME}/Library/Application Support/Name-Of-The-App/
) to store data.As I have figured out, maybe you should use something like
fs.mkdir(app.getPath('userData') + '/storage')
andfs.mkdir(app.getPath('userData') + '/storage/main.db')
, etc. to avoid raisingIO Error: No such file or directory
, and handle theerr
argument of the callback function correctly since theerr
might told you that the directory already exists (which shouldn't be handled as an error).That would be similar in
ipcMain.on('doImport', ...)
andsetupExportHandler(...)
.By the way:
sudo
cannot fix this issue/Application
instead of just start it in any folder cannot fix thisalert("已经有一个Console Lite在运行")
(or something like that)