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 syntax to specify restricted modules looks like this:

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

The following patterns are considered problems:

/*eslint no-restricted-modules: [2, "fs"]*/

var fs = require('fs'); /*error 'fs' module is restricted from being used.*/
/*eslint no-restricted-modules: [2, "cluster"]*/

var fs = require(' cluster '); /*error 'cluster' module is restricted from being used.*/

The following patterns are not considered problems:

/*eslint no-restricted-modules: [2, "fs"]*/

var crypto = require('crypto');


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

    "no-restricted-modules": [2,


This rule was introduced in ESLint 0.6.0.