-1

How can I edit a config.json file? I tried

const config = require("./config.json");
config.set("status", "online");

but it doesn't work.

Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
  • Does this answer your question? [How to update a value in a json file and save it through node.js](https://stackoverflow.com/questions/10685998/how-to-update-a-value-in-a-json-file-and-save-it-through-node-js) – Zsolt Meszaros Apr 07 '22 at 14:31

1 Answers1

0

You need to read in the file with something like fs.readFile then modify the content of the file and write back to it with fs.writeFile.

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127