VueJS Webapp with Electron and Javascript: JSON File Read/Write Issue when Building Executable

I am developing a web application using VueJS and building it with Electron. I have a common file that contains information which needs to be read and written at runtime, acting like a database between sessions, by a concurrent JS script.

Any help or guidance on this issue would be greatly appreciated.

Thank you!

The script that reads this file is a NetworkDiscovery.js script running in the background (with concurrently npm package), which waits to receive an IP address and then saves it in this JSON file.

Here is the path insertion in NetworkDiscovery.js:

const ENVIRONMENT_VAR_DOTENV_PATH = path.resolve(__dirname, '.env');

When I run everything with npm run dev, the JSON file reading and writing work correctly. However, when I use the Electron executable, the writing process fails. It reads the file correctly but does not write to it, indicating an incorrect path. How is it possible that the read operation works but the write operation does not, given the same path?

If I launch the .exe from Windows terminal it prints the same path both in reading and writing…

I have tried both JSON files and dotenv files. I have looked into electron-store and similar add-ons, but I believe they do not work since they are meant for VueJS, whereas the discovery script is a parallel running JS file.