string<string> | <Object>
position<integer> | <null> Default:
string to the file specified by
string is not a string, or an
object with an own
toString function property, then an exception is thrown.
position refers to the offset from the beginning of the file where this data
should be written. If
typeof position !== 'number' the data will be written at
the current position. See
encoding is the expected string encoding.
The callback will receive the arguments
(err, written, string) where
specifies how many bytes the passed string required to be written. Bytes
written is not necessarily the same as string characters written. See
It is unsafe to use
fs.write() multiple times on the same file without waiting
for the callback. For this scenario,
On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.
On Windows, if the file descriptor is connected to the console (e.g.
fd == 1
stdout) a string containing non-ASCII characters will not be rendered
properly by default, regardless of the encoding used.
It is possible to configure the console to render UTF-8 properly by changing the
active codepage with the
chcp 65001 command. See the chcp docs for more