Search code examples
node.jselectronfselectron-builder

Cannot Write File in Electron App After Build


I know this is a repetitious question but i can't find any answer
I want to store my electron app data in a local json file
This works very good but after packaging and building it doesn't work
I tried to run app in administrator but that doesn't work again!

i don't know how to solve this problem

There is a way to store data in electron app No Matter How

thanks


Solution

  • Where are you saving this file? Unless you have admin access, you can't save to certain directories because that would expose a lot of potential security holes of written apps.

    There was a package written that allows you to save data in a file for your app, making use of the path of app.getPath("userData"). This is the magic path you need to be using, app.getPath("userData"). If you aren't saving your data to this path, you will require admin access.

    That package although makes use of outdated security practices, so if you want to still save your electron data to a file with better practices (ie. using IPC instead of the remote module), I'd recommend this template that I am an author of.