fs.readFileSync() returns a buffer if no encoding is provided. Either pass an encoding or as this fix does, call toString(). An error was being created when .replace() was being called on the buffer object