Some while ago I started learning Vue.js and a short while after, I started a bigger project, not keeping in mind, that Javascript has limited options to interact with the local file system.
I set up the project via vue-cli, so I have to start the website via npm start
.
Said project consist of a visual editor for JSON Files. When I wanted to implement the save button, I recognized that it's a quite difficult task to make is write/save (and maybe read in the future) a JSON file to my local machine.
I already tried using node's fs
library, thinking it would work, because it is launched with node.
I also tried several external libraries e.g. the write-json-file
npm lib.
I'm getting to a point where I'm out of ideas and would do pretty much anything thats necessary to make it work.
There are 3 ways to do this.
Write to local storage
Create a Blob and invoke an event to download it
Wrap it into a electron app and use node
fs
module to save fileI can show you a sample here for these 3 cases
index.html
test.js (Write to local storage)
Create a Blob and invoke a event to download it
only change for saveFile func
Wrap it into an Electron app and use node
fs
module to save fileChange for saveFile func
Then use Electron to wrap it
electron ./index.html