Ask coding questions

← Back to all posts
Nodejs Fs Not Writing File
JakeHu2020

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?

Voters
JakeHu2020
Comments
hotnewtop
JakeHu2020

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

Coder100

you never called the addData function silly!

JakeHu2020

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

Coder100

well that's not going to help make it better

show the error that was displayed @JakeHu2020

JakeHu2020

@Coder100 There is no error somehow

Xenity

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