Disallow Node modules (no-restricted-modules)

Disallowing usage of specific node modules can be useful if you want to control the available methods, a developer can use, to implement a feature.

This way you can block usage of the fs module if you want disallow file system access. Blocking the os module can be useful if you don’t want to allow any operating system specific code.

Rule Details

This rule allows you to specify modules that you don’t want to use in your application.

The following patterns are considered warnings:

config: no-restricted-modules: [2, "fs"]

var fs = require('fs');

config: no-restricted-modules: [2, "cluster"]

var fs = require(' cluster ');

The following patterns are not warnings:

config: no-restricted-modules: [2, "fs"]

var crypto = require('crypto');


The syntax to specify restricted modules looks like this:

"no-restricted-modules": [<enabled>, <...moduleNames>]


To restrict the use of all Node.js core modules (via https://github.com/joyent/node/tree/master/lib):

    "no-restricted-modules": [2,


This rule was introduced in ESLint 0.6.0.