This seems like a solved problem but I am unable to find a solution for it.
Basically, I read a JSON file, change a key, and write back the new JSON to the same file
Another workaround would be to make use of prettier to format the JSON. The example below is using 'json' parser but it could also use 'json5', see list of valid parsers.
const prettier = require("prettier"); console.log(prettier.format(JSON.stringify(object),{ semi: false, parser: "json" }));