Skip to main content
accessSync - node__fs.d.ts - Node documentation
function accessSync

Usage in Deno

```typescript import { accessSync } from "node:node__fs.d.ts"; ```
accessSync(
path: PathLike,
mode?: number,
): void
Synchronously 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_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` for possible values of `mode`. If any of the accessibility checks fail, an `Error` will be thrown. Otherwise, the method will return `undefined`. ```js import { accessSync, constants } from 'node:fs'; try { accessSync('etc/passwd', constants.R_OK | constants.W_OK); console.log('can read/write'); } catch (err) { console.error('no access!'); } ```

Parameters

path: PathLike
optional
mode: number = fs.constants.F_OK

Return Type

void