# no-restricted-modules

Rule `eslint/no-restricted-modules`. Disallow specified modules when loaded by `require`

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 1.2M weekly downloads of presets that enable it
- Trend: +5.8% last quarter
- Rank: #1569 by reach, #1487 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-restricted-modules` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-restricted-modules) |

## Code examples

### Incorrect: the rule reports this

```js
const fs = require('fs');
const cluster = require('cluster');
```

```js
const cluster = require('cluster');
```

```js
const pick = require('lodash/pick');
```

### Correct: the rule accepts this

```js
const crypto = require('crypto');
```

```js
/*eslint no-restricted-modules: ["error", {
    "paths": ["fs", "cluster"],
    "patterns": ["lodash/*", "!lodash/pick"]
}]*/

const crypto = require('crypto');
const pick = require('lodash/pick');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "no-restricted-modules": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |

## Related rules

- [eslint/consistent-this](https://lintradar.dev/rules/eslint/consistent-this.md): Enforce consistent naming when capturing the current execution context
- [eslint/no-invalid-this](https://lintradar.dev/rules/eslint/no-invalid-this.md): Disallow use of `this` in contexts where the value of `this` is `undefined`
- [eslint/max-depth](https://lintradar.dev/rules/eslint/max-depth.md): Enforce a maximum depth that blocks can be nested
- [eslint/max-lines](https://lintradar.dev/rules/eslint/max-lines.md): Enforce a maximum number of lines per file
- [eslint/max-params](https://lintradar.dev/rules/eslint/max-params.md): Enforce a maximum number of parameters in function definitions
- [eslint/no-implicit-coercion](https://lintradar.dev/rules/eslint/no-implicit-coercion.md): Disallow shorthand type conversions

---

Web page: https://lintradar.dev/rules/eslint/no-restricted-modules. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
