Reputation: 331
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?
Upvotes: 32
Views: 11236
Reputation: 3393
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'
],
Upvotes: 3
Reputation: 17
convert to es5 by writing export default { } instead of module.export = {}
Upvotes: 0
Reputation: 47871
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.
Upvotes: 36