File is visible to the calling process.
File is visible to the calling process. This is useful for determining if a file exists, but says nothing about rwx permissions. Default if no mode is specified.
Flag indicating that data will be appended to the end of the file.
Flag indicating that data will be appended to the end of the file.
Flag indicating to create the file if it does not already exist.
Flag indicating to create the file if it does not already exist.
When set, an attempt will be made to minimize caching effects of file I/O.
When set, an attempt will be made to minimize caching effects of file I/O.
Flag indicating that the open should fail if the path is not a directory.
Flag indicating that the open should fail if the path is not a directory.
Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists.
Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists.
Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file.
Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only.
Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one).
Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one).
Flag indicating that the open should fail if the path is a symbolic link.
Flag indicating that the open should fail if the path is a symbolic link.
Flag indicating to open the file in nonblocking mode when possible.
Flag indicating to open the file in nonblocking mode when possible.
Flag indicating to open a file for read-only access.
Flag indicating to open a file for read-only access.
Flag indicating to open a file for read-write access.
Flag indicating to open a file for read-write access.
Flag indicating to open the symbolic link itself rather than the resource it is pointing to.
Flag indicating to open the symbolic link itself rather than the resource it is pointing to.
Flag indicating that the file is opened for synchronous I/O.
Flag indicating that the file is opened for synchronous I/O.
Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero.
Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero.
Flag indicating to open a file for write-only access.
Flag indicating to open a file for write-only access.
File can be read by the calling process.
File can be read by the calling process.
File type constant for a block-oriented device file.
File type constant for a block-oriented device file.
File type constant for a character-oriented device file.
File type constant for a character-oriented device file.
File type constant for a directory.
File type constant for a directory.
File type constant for a FIFO/pipe.
File type constant for a FIFO/pipe.
File type constant for a symbolic link.
File type constant for a symbolic link.
Bit mask used to extract the file type code.
Bit mask used to extract the file type code.
File type constant for a regular file.
File type constant for a regular file.
File type constant for a socket.
File type constant for a socket.
File can be written by the calling process.
File can be written by the calling process.
File can be executed by the calling process.
Tests a user's permissions for the file specified by path.
Tests a user's permissions for the file specified by path. mode is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values.
the path (Buffer | String)
is a callback function that is invoked with a possible error argument. If any of the accessibility checks fail, the error argument will be populated.
fs.access(path[, mode], callback)
Tests a user's permissions for the file specified by path.
Tests a user's permissions for the file specified by path. mode is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values.
the path (Buffer | String)
the optional mode
is a callback function that is invoked with a possible error argument. If any of the accessibility checks fail, the error argument will be populated.
fs.access(path[, mode], callback)
Synchronous version of fs.access().
Synchronous version of fs.access(). This throws if any accessibility checks fail, and does nothing otherwise.
the path (Buffer | String)
the optional mode
fs.accessSync(path[, mode])
Alias for emitter.on(eventName, listener).
Alias for emitter.on(eventName, listener).
emitter.addListener(eventName, listener)
on()
Asynchronously append data to a file, creating the file if it does not yet exist.
Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer.
the filename or file descriptor (Buffer | String | Number)
the data to append (Buffer | String)
the callback function
fs.appendFile(file, data[, options], callback)
Asynchronously append data to a file, creating the file if it does not yet exist.
Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer.
the filename or file descriptor (Buffer | String | Number)
the data to append (Buffer | String)
the callback function
fs.appendFile(file, data[, options], callback)
The synchronous version of fs.appendFile().
The synchronous version of fs.appendFile().
the filename or file descriptor (Buffer | String | Number)
the data to append (Buffer | String)
undefined.
Asynchronous chmod(2).
Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback.
the file or directory path (Buffer | String)
the file or directory mode
the completion callback.
Synchronous chmod(2).
Synchronous chmod(2).
the file or directory path (Buffer | String)
the file or directory mode
undefined.
Asynchronous chown(2).
Asynchronous chown(2). No arguments other than a possible exception are given to the completion callback.
the file or directory path (Buffer | String)
the user ID
the group ID
the completion callback.
Synchronous chown(2).
Synchronous chown(2).
the file or directory path (Buffer | String)
the user ID
the group ID
undefined.
Asynchronous close(2).
Asynchronous close(2). No arguments other than a possible exception are given to the completion callback.
fs.close(fd, callback)
Synchronous close(2).
Returns a new ReadStream object.
Returns a new ReadStream object. (See Readable Stream). Be aware that, unlike the default value set for highWaterMark on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter.
the path (Buffer | String)
the optional stream options
fs.createReadStream(path[, options])
Returns a new WriteStream object.
Returns a new WriteStream object.
the path (Buffer | String)
the optional stream options
fs.createWriteStream(path[, options])
Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
Returns true if the event had listeners, false otherwise.
the event name
the event arguments
emitter.emit(name[, arg1][, arg2][, ...])
fs.exists() should not be used to check if a file exists before calling fs.open().
fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.
fs.existsSync(path)
Asynchronous fchmod(2).
Asynchronous fchmod(2). No arguments other than a possible exception are given to the completion callback.
fs.fchmod(fd, mode, callback)
Synchronous fchmod(2).
Asynchronous fchown(2).
Asynchronous fchown(2). No arguments other than a possible exception are given to the completion callback.
the file or directory path (Buffer | String)
the user ID
the group ID
the completion callback.
Synchronous fchown(2).
Synchronous fchown(2).
the file or directory path (Buffer | String)
the user ID
the group ID
undefined.
Asynchronous fdatasync(2).
Asynchronous fdatasync(2). No arguments other than a possible exception are given to the completion callback.
fs.fdatasync(fd, callback)
Synchronous fdatasync(2).
Asynchronous fstat(2).
Asynchronous fstat(2). The callback gets two arguments (err, stats) where stats is an fs.Stats object. fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd.
the file descriptor
the completion callback.
Synchronous fstat(2).
Asynchronous fsync(2).
Asynchronous fsync(2). No arguments other than a possible exception are given to the completion callback.
the file descriptor
the completion callback.
Synchronous fsync(2).
Asynchronous ftruncate(2).
Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback. If the file referred to by the file descriptor was larger than length bytes, only the first length bytes will be retained in the file.
the file descriptor
the desired length
the completion callback.
Synchronous ftruncate(2).
Synchronous ftruncate(2).
the file descriptor
the desired length
undefined.
Change the file timestamps of a file referenced by the supplied file descriptor.
Change the file timestamps of a file referenced by the supplied file descriptor.
fs.futimes(fd, atime, mtime, callback)
Synchronous version of fs.futimes().
Synchronous version of fs.futimes().
undefined.
fs.futimesSync(fd, atime, mtime)
Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.
Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.
emitter.getMaxListeners()
setMaxListeners()
Asynchronous lchmod(2).
Asynchronous lchmod(2). No arguments other than a possible exception are given to the completion callback.
fs.lchmod(path, mode, callback)
Synchronous lchmod(2).
Synchronous lchmod(2).
the path (Buffer | String)
the mode (Integer)
undefined.
fs.lchmodSync(path, mode)
Asynchronous lchown(2).
Asynchronous lchown(2). No arguments other than a possible exception are given to the completion callback.
the path (Buffer | String)
the user ID
the group ID
the completion callback.
fs.lchown(path, uid, gid, callback)
Synchronous chown(2).
Synchronous chown(2).
the path (Buffer | String)
the user ID
the group ID
undefined.
Asynchronous link(2).
Asynchronous link(2). No arguments other than a possible exception are given to the completion callback.
the existing path
the new path
the completion callback.
fs.link(srcpath, dstpath, callback)
Synchronous link(2).
Synchronous link(2).
the existing path
the new path
undefined.
Returns the number of listeners listening to the event named eventName.
Returns the number of listeners listening to the event named eventName.
emitter.listenerCount(eventName)
Returns a copy of the array of listeners for the event named eventName.
Returns a copy of the array of listeners for the event named eventName.
emitter.listeners(eventName)
Asynchronous lstat(2).
Asynchronous lstat(2). lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to.
the path (Buffer | String)
The callback gets two arguments (err, stats) where stats is a fs.Stats object.
Synchronous lstat(2).
Asynchronous mkdir(2).
Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0o777.
fs.mkdir(path[, mode], callback)
Asynchronous mkdir(2).
Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0o777.
fs.mkdir(path[, mode], callback)
Synchronous mkdir(2).
Creates a unique temporary directory.
Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. The created folder path is passed as a string to the callback's second parameter. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.
the prefix
the callback
fs.mkdtemp(prefix[, options], callback)
Creates a unique temporary directory.
Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. The created folder path is passed as a string to the callback's second parameter. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.
the prefix
the optional encoding setting
the callback
fs.mkdtemp(prefix[, options], callback)
The synchronous version of fs.mkdtemp().
The synchronous version of fs.mkdtemp(). Returns the created folder path. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.
the prefix
the optional encoding setting
Adds the listener function to the end of the listeners array for the event named eventName.
Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
Returns a reference to the EventEmitter so calls can be chained.
emitter.on(eventName, listener)
Adds a one time listener function for the event named eventName.
Adds a one time listener function for the event named eventName. This listener is invoked only the next time eventName is triggered, after which it is removed.
emitter.once(eventName, listener)
Asynchronous file open.
Asynchronous file open. See open(2).
the path (Buffer | String)
flags can be:
the callback gets two arguments (err, fd)
fs.open(path, flags[, mode], callback)
Asynchronous file open.
Asynchronous file open. See open(2).
the path (Buffer | String)
flags can be:
sets the file mode (permission and sticky bits), but only if the file was created. It defaults to 0666, readable and writable.
the callback gets two arguments (err, fd)
fs.open(path, flags[, mode], callback)
Synchronous version of fs.open().
Synchronous version of fs.open().
the path (Buffer | String)
the flags
the file mode
an integer representing the file descriptor.
fs.openSync(path, flags[, mode])
Read data from the file specified by fd.
Read data from the file specified by fd.
is the file descriptor
is the buffer that the data will be written to.
is the offset in the buffer to start writing at.
is an integer specifying the number of bytes to read.
is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
the callback is given the three arguments, (err, bytesRead, buffer).
Asynchronously reads the entire contents of a file.
Asynchronously reads the entire contents of a file.
filename or file descriptor
The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.
fs.readFile(file[, options], callback)
Asynchronously reads the entire contents of a file.
Asynchronously reads the entire contents of a file.
filename or file descriptor
the encoding (default = null)
The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.
fs.readFile(file[, options], callback)
Asynchronously reads the entire contents of a file.
Asynchronously reads the entire contents of a file.
filename or file descriptor
the optional settings
The callback is passed two arguments (err, data), where data is the contents of the file. If no encoding is specified, then the raw buffer is returned.
fs.readFile(file[, options], callback)
Synchronous version of fs.readFile.
Synchronous version of fs.readFile.
filename or file descriptor <String> | <Buffer> | <Integer>
the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.
fs.readFileSync(file[, options])
Synchronous version of fs.readFile.
Synchronous version of fs.readFile. Returns the contents of the file.
filename or file descriptor <String> | <Buffer> | <Integer>
the optional encoding <Object> | <String>
the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.
fs.readFileSync(file[, options])
Synchronous version of fs.readFile.
Synchronous version of fs.readFile. Returns the contents of the file.
filename or file descriptor <String> | <Buffer> | <Integer>
the optional encoding <Object> | <String>
the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.
fs.readFileSync(file[, options])
Synchronous version of fs.read().
Synchronous version of fs.read().
is the file descriptor
is the buffer that the data will be written to.
is the offset in the buffer to start writing at.
is an integer specifying the number of bytes to read.
is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.
the number of bytesRead.
Asynchronous readdir(3).
Asynchronous readdir(3). Reads the contents of a directory.
the path (Buffer | String)
the callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.
fs.readdir(path[, options], callback)
Asynchronous readdir(3).
Asynchronous readdir(3). Reads the contents of a directory.
the path (Buffer | String)
the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the filenames passed to the callback. If the encoding is set to 'buffer', the filenames returned will be passed as Buffer objects.
the callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.
fs.readdir(path[, options], callback)
Synchronous readdir(3).
Synchronous readdir(3).
the path (Buffer | String)
the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the filenames passed to the callback. If the encoding is set to 'buffer', the filenames returned will be passed as Buffer objects.
an array of filenames excluding '.' and '..'.
Asynchronous readlink(2).
Asynchronous readlink(2). If the encoding is set to 'buffer', the link path returned will be passed as a Buffer object.
the path (Buffer | String)
the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the link path passed to the callback.
the callback gets two arguments (err, linkString).
fs.readlink(path[, options], callback)
Synchronous readlink(2).
Synchronous readlink(2).
the path (Buffer | String)
the optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the link path passed to the callback. If the encoding is set to 'buffer', the link path returned will be passed as a Buffer object.
the symbolic link's string value.
Asynchronous realpath(2).
Asynchronous realpath(2). The callback gets two arguments (err, resolvedPath). May use process.cwd to resolve relative paths.
The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the path passed to the callback. If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.
fs.realpath(path[, options], callback)
Asynchronous realpath(2).
Asynchronous realpath(2). May use process.cwd to resolve relative paths.
the path
The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the path passed to the callback.
The callback gets two arguments (err, resolvedPath). If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.
fs.realpath(path[, options], callback)
Synchronous realpath(3).
Synchronous realpath(3). Only paths that can be converted to UTF8 strings are supported. The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use for the returned value. If the encoding is set to 'buffer', the path returned will be passed as a Buffer object.
the resolved path.
fs.realpathSync(path[, options])
Removes all listeners, or those of the specified eventName.
Removes all listeners, or those of the specified eventName.
Note that it is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter so calls can be chained.
emitter.removeAllListeners([eventName])
Removes all listeners, or those of the specified eventName.
Removes all listeners, or those of the specified eventName.
Note that it is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter so calls can be chained.
emitter.removeAllListeners([eventName])
Removes the specified listener from the listener array for the event named eventName.
Removes the specified listener from the listener array for the event named eventName. removeListener will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then removeListener must be called multiple times to remove each instance.
Note that once an event has been emitted, all listeners attached to it at the time of emitting will be called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution will not remove them from emit() in progress. Subsequent events will behave as expected.
emitter.removeListener(eventName, listener)
Asynchronous rename(2).
Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback.
fs.rename(oldPath, newPath, callback)
Synchronous rename(2).
Synchronous rename(2).
undefined.
fs.renameSync(oldPath, newPath)
Asynchronous rmdir(2).
Asynchronous rmdir(2). No arguments other than a possible exception are given to the completion callback.
fs.rmdir(path, callback)
Synchronous rmdir(2).
By default EventEmitters will print a warning if more than 10 listeners are added for a particular event.
By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. Obviously, not all events should be limited to just 10 listeners. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) for to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter so calls can be chained.
emitter.setMaxListeners(n)
Asynchronous stat(2).
Synchronous stat(2).
Asynchronous symlink(2).
Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using 'junction', the target argument will automatically be normalized to absolute path.
fs.symlink(target, path[, type], callback)
Asynchronous symlink(2).
Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using 'junction', the target argument will automatically be normalized to absolute path.
fs.symlink(target, path[, type], callback)
Synchronous symlink(2).
Synchronous symlink(2).
undefined.
fs.symlinkSync(target, path[, type])
Asynchronous truncate(2).
Asynchronous truncate(2). No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case, fs.ftruncate() is called.
the path <String> | <Buffer>
the length
the completion callback.
fs.truncate(path, length, callback)
Synchronous truncate(2).
Synchronous truncate(2). In this case, fs.ftruncateSync() is called.
the path or file descriptor - <String> | <Buffer> | <Integer>
the length
undefined.
fs.truncateSync(path, length)
Asynchronous unlink(2).
Asynchronous unlink(2). No arguments other than a possible exception are given to the completion callback.
fs.unlink(path, callback)
Synchronous unlink(2).
Stop watching for changes on filename.
Stop watching for changes on filename. If listener is specified, only that particular listener is removed. Otherwise, all listeners are removed and you have effectively stopped watching filename.
Calling fs.unwatchFile() with a filename that is not being watched is a no-op, not an error.
Note: fs.watch() is more efficient than fs.watchFile() and fs.unwatchFile(). fs.watch() should be used instead of fs.watchFile() and fs.unwatchFile() when possible.
fs.unwatchFile(filename[, listener])
Change file timestamps of the file referenced by the supplied path.
Change file timestamps of the file referenced by the supplied path.
Note: the arguments atime and mtime of the following related functions does follow the below rules:
If the value is a numberable string like '123456789', the value would get converted to corresponding number. If the value is NaN or Infinity, the value would get converted to Date.now().
fs.utimes(path, atime, mtime, callback)
Synchronous version of fs.utimes().
Synchronous version of fs.utimes().
undefined.
fs.utimesSync(path, atime, mtime)
Watch for changes on filename, where filename is either a file or a directory.
Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.
The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.
The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.
the filename (Buffer | String)
fs.watch(filename[, options][, listener])
Watch for changes on filename, where filename is either a file or a directory.
Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.
The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.
The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.
the filename (Buffer | String)
the listener callback gets two arguments (eventType, filename). eventType is either 'rename' or 'change', and filename is the name of the file which triggered the event.
fs.watch(filename[, options][, listener])
Watch for changes on filename, where filename is either a file or a directory.
Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher.
The second argument is optional. If options is provided as a string, it specifies the encoding. Otherwise options should be passed as an object.
The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.
the filename (Buffer | String)
the callback function
fs.watch(filename[, options][, listener])
Watch for changes on filename.
Watch for changes on filename. The callback listener will be called each time the file is accessed.
The options argument may be omitted. If provided, it should be an object. The options object may contain a boolean named persistent that indicates whether the process should continue to run as long as files are being watched. The options object may specify an interval property indicating how often the target should be polled in milliseconds. The default is { persistent: true, interval: 5007 }.
the filename (Buffer | String)
the callback
Watch for changes on filename.
Watch for changes on filename. The callback listener will be called each time the file is accessed.
The options argument may be omitted. If provided, it should be an object. The options object may contain a boolean named persistent that indicates whether the process should continue to run as long as files are being watched. The options object may specify an interval property indicating how often the target should be polled in milliseconds. The default is { persistent: true, interval: 5007 }.
the filename (Buffer | String)
the callback
Write string to the file specified by fd.
Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. Unlike when writing buffer, the entire string must be written. No substring may be specified. This is because the byte offset of the resulting data may not be the same as the string offset. Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended. 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.
the file descriptor
the data to write
will receive the arguments (err, written, string) where written specifies how many bytes the passed string required to be written. Note that bytes written is not the same as string characters. See Buffer.byteLength.
fs.write(fd, string[, position[, encoding]], callback)
Write string to the file specified by fd.
Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. Unlike when writing buffer, the entire string must be written. No substring may be specified. This is because the byte offset of the resulting data may not be the same as the string offset. Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended. 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.
the file descriptor
the data to write
is the expected string encoding.
will receive the arguments (err, written, string) where written specifies how many bytes the passed string required to be written. Note that bytes written is not the same as string characters. See Buffer.byteLength.
fs.write(fd, string[, position[, encoding]], callback)
Write string to the file specified by fd.
Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. Unlike when writing buffer, the entire string must be written. No substring may be specified. This is because the byte offset of the resulting data may not be the same as the string offset. Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended. 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.
the file descriptor
the data to write
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 pwrite(2).
is the expected string encoding.
will receive the arguments (err, written, string) where written specifies how many bytes the passed string required to be written. Note that bytes written is not the same as string characters. See Buffer.byteLength.
fs.write(fd, string[, position[, encoding]], callback)
Write buffer to the file specified by fd.
Write buffer to the file specified by fd.
Note: that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended.
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.
the file descriptor
the buffer containing the data to write If typeof position !== 'number', the data will be written at the current position. See pwrite(2).
will be given three arguments (err, written, buffer) where written specifies how many bytes were written from buffer.
fs.write(fd, buffer[, offset[, length[, position]]], callback)
Write buffer to the file specified by fd.
Write buffer to the file specified by fd.
Note: that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. For this scenario, fs.createWriteStream is strongly recommended.
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.
the file descriptor
the buffer containing the data to write
determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.
the optional length of the data to write
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 pwrite(2).
will be given three arguments (err, written, buffer) where written specifies how many bytes were written from buffer.
fs.write(fd, buffer[, offset[, length[, position]]], callback)
Asynchronously writes data to a file, replacing the file if it already exists.
Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer. The encoding option is ignored if data is a buffer. It defaults to 'utf8'
fs.writeFile(file, data[, options], callback)
Asynchronously writes data to a file, replacing the file if it already exists.
Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer. The encoding option is ignored if data is a buffer. It defaults to 'utf8'
fs.writeFile(file, data[, options], callback)
The synchronous version of fs.writeFile().
The synchronous version of fs.writeFile().
undefined.
fs.writeFileSync(file, data[, options])
Write string to the file specified by fd.
Write string to the file specified by fd.
the given file descriptor
the given string
fs.writeSync(fd, string[, position[, encoding]])
Write string to the file specified by fd.
Write string to the file specified by fd.
the given file descriptor
the given string
is the expected string encoding.
fs.writeSync(fd, string[, position[, encoding]])
Write string to the file specified by fd.
Write string to the file specified by fd.
the given file descriptor
the given string
refers to the offset from the beginning of the file where this data should be written.
fs.writeSync(fd, string[, position[, encoding]])
Write string to the file specified by fd.
Write string to the file specified by fd.
the given file descriptor
the given string
refers to the offset from the beginning of the file where this data should be written.
is the expected string encoding.
fs.writeSync(fd, string[, position[, encoding]])
Write buffer to the file specified by fd.
Write buffer to the file specified by fd.
the given file descriptor
the given buffer
fs.writeSync(fd, buffer[, offset[, length[, position]]])
Write buffer to the file specified by fd.
Write buffer to the file specified by fd.
the given file descriptor
the given buffer
determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.
the optional length of the data to write
refers to the offset from the beginning of the file where this data should be written.
fs.writeSync(fd, buffer[, offset[, length[, position]]])
Test whether or not the given path exists by checking with the file system.
Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false.
(Since version 1.0.0) Use fs.stat() or fs.access() instead.
fs.exists('/etc/passwd', (exists) => { ... })
File System Singleton