error 'document' is not defined : eslint / React

前端 未结 4 1095
青春惊慌失措
青春惊慌失措 2021-02-04 23:47

I\'m building a React app, with create-react-app.

I got the following error when running ESLint:
8:3 error \'document\' is not defined no-undef.

4条回答
  •  醉梦人生
    2021-02-05 00:22

    If you have .eslintrc.json file then add following code snippet.

    {
        ...otherSettings,
        "env": {
            "browser": true,
            "node": true
        }
    }
    

    if you do not have .eslintrc.json then you can add these settings in you package.json file.

    {
        ...otherSettings,
        "eslintConfig": {
          "globals": {
            "window": true
          }
        }
    }
    

提交回复
热议问题