So, here's the thing.
I need a method to save/load data in a webpage from one session to another.
I tried a few of the answers found here, and the one I felt would work the best for me is this one:
const fs = require('fs');
fs.writeFileSync('test.txt', data);
var text = fs.readFileSync('test.txt','utf8')
Since I'm doing it through an html page, I made sure to declare all the JavaScript libraries('require', 'fs' and 'bluebird') in the main page.
<script type="text/javascript" src="./bluebird.js"></script>
<script type="text/javascript" src="./require.js"></script>
<script type="text/javascript" src="./fs.js"></script>
and even tried it as script type="module", but I'm still getting these errors:
Uncaught Error: Module name "bluebird" has not been loaded yet for context: _. Use require([])
Uncaught TypeError: Cannot set properties of undefined (setting 'requirejsVars')
Uncaught ReferenceError: require is not defined
And I really have no idea what I'm doing wrong.
I also tried using Local Storage and it works perfectly for what I want, except that I need the files to be saved in a pre-determined location, so if there's a way to do that through Local Storage, that's even better.
Also, this is a personal project, so I'll just run it locally, without a server or anything.