NodeJS: Data argument must be of type string/Buffer/TypedArray/DataView, how to fix?

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())

Leave a Comment