Skip to main content
fs/promises - Node documentation

Usage in Deno

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 accessibilitychecks to be performed. mode should be either the value fs.constants.F_OK or 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 forpossible values of mode.

f
appendFile

Asynchronously append data to a file, creating the file if it does not yetexist. 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 italready exists.

f
cp

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

f
glob

Retrieves the files matching the specified pattern.

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 asymbolic link, then the link is not dereferenced: instead, the timestamps ofthe symbolic link itself are changed.

f
mkdir

Asynchronously creates a directory.

f
mkdtemp

Creates a unique temporary directory. A unique directory name is generated byappending six random characters to the end of the provided prefix. Due toplatform inconsistencies, avoid trailing X characters in prefix. Someplatforms, notably the BSDs, can return more than six random characters, andreplace 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 the fs.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 len bytes.

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, anAsyncIterable, or anIterable object.

f
lchmod

Changes the permissions on a symbolic link.

Interfaces

Variables

v
constants
No documentation available