Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.eslintrc.js 'module' is not defined

I'm getting 'module' is not defined error from the eslint in .eslintrc.js file.

What does this mean and how do I fix it?

vs code error message screenshot

like image 883
lotaquestions Avatar asked Sep 02 '25 10:09

lotaquestions


2 Answers

You need to add an environment setting inside your .eslintrc.js file, i.e.:

...
env: {
    node: true
},
...

That said, the error in the .eslintrc.js file itself should only appear in Visual Studio Code, because ESLint ignores file names that start with a dot per default.

like image 144
GOTO 0 Avatar answered Sep 05 '25 17:09

GOTO 0


Be careful blindly setting the node environment in all projects. If the application is not going to be running on node (e.g. a browser application), don't set the whole project to use the node environment just to prevent linting errors in the config file. It's better to just not lint this file instead, or potentially set up a different set of rules for it.

To ignore it, just add the following to the .eslintrc.js file.

'ignorePatterns': [
  '.eslintrc.js'
],
like image 36
Geraint Anderson Avatar answered Sep 05 '25 17:09

Geraint Anderson