Index - Node documentation

Usage

import * as mod from "node:fs/promises";

The fs/promises API provides asynchronous file system methods that return promises.

The promise APIs use the underlying Node.js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur.

Functions

f
access

Tests a user's permissions for the file or directory specified by path. The mode argument is an optional integer that specifies the accessibility checks to be performed. mode should be either the value fs.constants.F_OKor a mask consisting of the bitwise OR of any of fs.constants.R_OK,fs.constants.W_OK, and fs.constants.X_OK (e.g.fs.constants.W_OK | fs.constants.R_OK). Check File access constants for possible values of mode.

f
appendFile

Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a Buffer.

f
chmod

Changes the permissions of a file.

f
chown

Changes the ownership of a file.

f
copyFile

Asynchronously copies src to dest. By default, dest is overwritten if it already exists.

f
cp

Asynchronously copies the entire directory structure from src to dest, including subdirectories and files.

f
lchown

Changes the ownership on a symbolic link.

f
lstat

Equivalent to fsPromises.stat() unless path refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to. Refer to the POSIX lstat(2) document for more detail.

f
lutimes

Changes the access and modification times of a file in the same way as fsPromises.utimes(), with the difference that if the path refers to a symbolic link, then the link is not dereferenced: instead, the timestamps of the symbolic link itself are changed.

f
mkdir

Asynchronously creates a directory.

f
mkdtemp

Creates a unique temporary directory. A unique directory name is generated by appending six random characters to the end of the provided prefix. Due to platform inconsistencies, avoid trailing X characters in prefix. Some platforms, notably the BSDs, can return more than six random characters, and replace trailing X characters in prefix with random characters.

f
open

Opens a FileHandle.

f
opendir

Asynchronously open a directory for iterative scanning. See the POSIX opendir(3) documentation for more detail.

f
readdir

Reads the contents of a directory.

f
readFile

Asynchronously reads the entire contents of a file.

f
realpath

Determines the actual location of path using the same semantics as thefs.realpath.native() function.

f
rename

Renames oldPath to newPath.

f
rm

Removes files and directories (modeled on the standard POSIX rm utility).

f
rmdir

Removes the directory identified by path.

f
stat
No documentation available
f
statfs
No documentation available
f
truncate

Truncates (shortens or extends the length) of the content at path to lenbytes.

f
utimes

Change the file system timestamps of the object referenced by path.

f
watch

Returns an async iterator that watches for changes on filename, where filenameis either a file or a directory.

f
writeFile

Asynchronously writes data to a file, replacing the file if it already exists.data can be a string, a buffer, an AsyncIterable, or an Iterable object.

f
lchmod

Changes the permissions on a symbolic link.

Interfaces

I
CreateReadStreamOptions
No documentation available
I
CreateWriteStreamOptions
No documentation available
I
FileChangeInfo
No documentation available
I
FileHandle
No documentation available
I
FileReadOptions
No documentation available
I
FileReadResult
No documentation available
I
FlagAndOpenMode
No documentation available
I
ReadableWebStreamOptions
No documentation available

Variables

v
constants
No documentation available