I have written a code where it coverts that I should be writting in a file (JSON) and gets read after in my node app. The problem is, if it gets uploaded in the web, this problem appears:
fs.writeFileSync("./newgenesis-sql-db/itemDatabase.json", o, (function(a) {
a ? console.log("Error writing file", a) : console.log("Successfully wrote file")
}
rmmz_managers.js:2036 ReferenceError: fs is not defined
Meaning it does not require the fs which is of course done via require(‘fs’). I have a hunch that this is because require.js is not uploaded, but even so, since it is via node, I opted to believe it should work. Do we have to attach it?
This is my code:
const jsonString = JSON.stringify(actorFiles)
fs.writeFileSync('./newgenesis-sql-db/actorDatabase.json', jsonString, err => {
if (err) {
console.log('Error writing file', err)
} else {
console.log('Successfully wrote file')
}
})
const jsonString2 = JSON.stringify(playerItems)
fs.writeFileSync('./newgenesis-sql-db/itemDatabase.json', jsonString2, err => {
if (err) {
console.log('Error writing file', err)
} else {
console.log('Successfully wrote file')
}
})
The intention was just to actually write the strings I placed inside the JSON. How can I make sure that it will be written on the JSON when the game gets uploaded online? Is there a way to write the texts I want in the JSON without using require(‘fs’) and if so, how?