Ask coding questions

← Back to all posts
Nodejs Fs Not Writing File
JakeHu2020 (21)

I'm coding a multiplayer game where the repl stores player information inside a file called Server.txt. Can you help tell me why when I write fs.writeFileSync(__dirname+"/Server.txt",'Text') It shows Nothing?

JakeHu2020 (21)

Actually nevermind, In "addData" I forgot to add a function that adds data rather than change data through ID.

Coder100 (18109)

you never called the addData function silly!

JakeHu2020 (21)

@Coder100 yes I did actually I just removed it because It didn't work.

Coder100 (18109)

well that's not going to help make it better

show the error that was displayed @JakeHu2020

JakeHu2020 (21)

@Coder100 There is no error somehow

Xenity (9)

try using fs.writeFile('Server.txt', 'Text', { flag: 'a+' }, err => { if (err) { console.error(err) } instead?