简体   繁体   English

如何解决这个错误:package.json » eslint-config-react-app/jest#overrides[0]: Environment key "jest/globals" is unknown

[英]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:无法使用sudo yarn build启动我的应用程序我收到此错误:

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

What would be a solution for this error?这个错误的解决方案是什么?

This is due to error in node_modules Delete node_modules from file directory manually and try running this code in terminal of VSCode:这是由于 node_modules 中的错误手动从文件目录中删除 node_modules 并尝试在 VSCode 的终端中运行此代码:

npm install

Update Package.json(Remove "react-app/jest" from extends array更新 Package.json(从扩展数组中删除“react-app/jest”

"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 works It should work.如果您正在使用 eslintconfig 删除它或从那里删除 react-app/jest 扩展数组并仅保留 react-app 运行 npm 安装并再次检查 它可以工作 它应该可以工作。

I had the same issue with npm.我对 npm 也有同样的问题。

Resolution took editing package.json分辨率带编辑 package.json

Find and remove the whole eslintConfig查找并删除整个 eslintConfig

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

also I had devDependencies that needed to be removed.我也有需要删除的 devDependencies。

  "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".我跑了“npm install”。 The error cleared.错误清除。 Then I added all of the above back into the package.json.然后我将以上所有内容添加回 package.json。 I ran "npm install" again with no errors.我再次运行“npm install”,没有任何错误。

npm install -- solved it for me npm 安装——帮我解决了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载在“package.json » eslint-config-react-app/jest”中声明的插件“jest”:无法读取未定义的属性(读取“meta”) - Failed to load plugin 'jest' declared in 'package.json » eslint-config-react-app/jest': Cannot read properties of undefined (reading 'meta') 无法加载在 'package.json » eslint-config-react-app#overrides[0]' 中声明的解析器 '@typescript-eslint/parser':找不到模块 'typescript' - Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' 使用 nodemon 重新部署我的 React 应用程序时出错,它一直在说“插件“反应”在“package.json » eslint-config-react”-app » 之间发生冲突 - Error when redeploying my react app with nodemon it keeps sayings "Plugin "react" was conflicted between "package.json » eslint-config-react"-app » 如何在package.json脚本字段中使用Jest的testNamePattern? - how to use testNamePattern of jest within package.json scripts field? Eslint 8.0.1 - 在配置中实现 jest 会引发错误 - Eslint 8.0.1 - implementing jest into config throws an error 使用现有的 package.json 安装 jest - Installing jest with an existing package.json 扩展 eslint-config-react-app 时 no-use-before-define 无效 - no-use-before-define has no effect when extending eslint-config-react-app 将环境变量从package.json传递到React应用 - Pass environment variable from package.json to React app 如何在 Create React App 的 jest config 中设置时区? - How do I set the timezone in jest config in Create React App? 如何在 Jest 中使用 ESLint - How to use ESLint with Jest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM