'How to solve this error: package.json » eslint-config-react-app/jest#overrides[0]: Environment key "jest/globals" is unknown

Unable to launch my app using sudo yarn build I am getting this error:

package.json » eslint-config-react-app/jest#overrides[0]:
   Environment key "jest/globals" is unknown

What would be a solution for this error?



Solution 1:[1]

Update Package.json(Remove "react-app/jest" from extends array

"eslintConfig": { "extends": [ "react-app" ] },

if you are using eslintconfig delete that or remove the react-app/jest from there extends array and keep only react-app Run npm install and check again It should work.

Solution 2:[2]

I had the same issue with npm.

Resolution took editing package.json

Find and remove the whole eslintConfig

"eslintConfig": {
  "extends": [
      "react-app",
      "react-app/jest"
  ]
},

also I had devDependencies that needed to be removed.

  "devDependencies": {
    "eslint": "7.30.0",
    "eslint-config-airbnb": "18.2.1",
    "eslint-config-prettier": "8.3.0",
    "eslint-plugin-import": "2.23.4",
    "eslint-plugin-jsx-a11y": "6.4.1",
    "eslint-plugin-prettier": "3.4.0",
    "eslint-plugin-react": "7.24.0",
    "eslint-plugin-react-hooks": "4.2.0",
    "prettier": "2.3.2"
  }

I ran "npm install". The error cleared. Then I added all of the above back into the package.json. I ran "npm install" again with no errors.

Solution 3:[3]

This is due to error in node_modules Delete node_modules from file directory manually and try running this code in terminal of VSCode :

npm install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Daniel Lord
Solution 3 Ramdev CM