So the error is saying the data
(second argument of the fs.writeFileSync function) should be a string or a buffer…etc but instead got a number.
To resolve, convert the second argument to string as shown:
fs.writeFileSync(configPath, parseInt(nextBlock, 10).toString())