#Problem saving to file using fs | NO ERRORS
11 messages · Page 1 of 1 (latest)
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
✅Marked as resolved by OP
you're using an absolute file path instead of a relative file path for your destination file, so you might be writing to an unexpected location
thats what i've been doing from every other file. besides, those and this file were both executed from my main index, and those paths are relative to the index.
ai cant fix it either and now im worried that its something on my computer alone or something. or maybe i made a dumb mistake. idk
I mean, have you tried using relative paths?
like ./ ? cause i did and it didnt work
Are you sure your code is even being reached? You should add console logs immediately before and after the lines you shared, and make sure both get logged
k
wait i know its being reached cause i have a console.log right before the file saving and it logs whats supposed to be saved but it never gets saved js config.gptThreads[thread.name] = { ownerId: interaction.user.id }; console.log(config); let jsonString = JSON.stringify(config, null, 2); fs.writeFileSync("commands/ai/config.json", jsonString, "utf-8");
turns out the file is being changed but for some reason the config isnt changing. but whne i print the config it is changed how its supposed to be. might be a problem with JSON