-
Notifications
You must be signed in to change notification settings - Fork 293
fs.writeFileSync not writing but doesn't give any errors. #2116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unable to reproduce the issue. The following code: const fs = require('fs');
const money = {};
const message = {author: {id: 0}};
money[message.author.id] = {
bank: 1000,
cash: 0,
};
fs.writeFileSync('../money.json', JSON.stringify(money)); properly creates {"0":{"bank":1000,"cash":0}} There is not enough information in your code snippet to reliably tell what the problem is, but the problem could be among these:
One possible mistake that you may be doing is this: const fs = require('fs');
const money = {};
const someAsyncStuff = f => setTimeout(f);
someAsyncStuff(() => {
const message = {author: {id: 0}};
money[message.author.id] = {
bank: 1000,
cash: 0,
};
});
fs.writeFileSync('../money.json', JSON.stringify(money)); where If you share the whole code, the problem will be revealed more easily. |
@Hakerh400 I tried fs.writeFile and it fixed it. Thank you. |
I try using this to write the values of my money file, but when I write it it doesn't save but it also doesn't give out an error. It worked on other projects that are running the same versions and on the same OS, but for some reason this doesn't work.
The money.json file currently looks like this
The text was updated successfully, but these errors were encountered: