module is not defined and process is not defined in eslint in visual studio code

后端 未结 3 1036
小鲜肉
小鲜肉 2021-02-04 22:57

I have installed eslint in my machine and i have used visual studio code i have certain modules and process to be exported When i try to use \"module\" or \"process\" it shows

相关标签:
3条回答
  • 2021-02-04 23:42

    You need to tell eslint that you are in a Node environment. My favourite way to do this for one-off files like gulpfile.js is to include this comment at the top:

    /* eslint-env node */
    
    0 讨论(0)
  • 2021-02-04 23:57

    You are probably trying to run this in node environment.

    The env section should look like this:

    "env": {
        "browser": true,
        "amd": true,
        "node": true
    },
    
    0 讨论(0)
  • 2021-02-04 23:58

    In your ESLint config file, simply add this:

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

    That should fix the "module" is not defined and "process" is not defined error.

    If you want to prevent ESLint from linting some globals then you will need to add the specific global variables in the globals section of the config.

    globals: {
      window: true,
      module: true
    }
    
    0 讨论(0)
提交回复
热议问题