---
url: /docs/guide/usage/linter/rules/node/no-sync.md
---

### What it does

Disallows synchronous methods from being called in Node.js code.

### Why is this bad?

In Node.js, most I/O is done through asynchronous methods. However, there are often
synchronous versions of the asynchronous methods. For example, `fs.exists()` and
`fs.existsSync()`. In some contexts, using synchronous operations is okay (if, as with
ESLint, you are writing a command line utility). However, in other contexts the use of
synchronous operations is considered a bad practice that should be avoided.

### Examples

Examples of **incorrect** code for this rule:

```js
fs.existsSync(somePath);

function foo() {
  var contents = fs.readFileSync(somePath).toString();
}
```

Examples of **correct** code for this rule:

```js
obj.sync();

async(function () {
  // ...
});
```

## Configuration

This rule accepts a configuration object with the following properties:

### allowAtRootLevel

type: `boolean`

default: `false`

Whether synchronous methods should be allowed at the top level of a file.

### ignores

type: `string[]`

default: `[]`

Function names to ignore.

## How to use

## Version

This rule was added in v1.71.0.

## References
