简体   繁体   English

(ESLint)在VS 2017 react项目中找不到模块'eslint-config-react-app'

[英](ESLint) Cannot find module 'eslint-config-react-app' in VS 2017 react project

We have a react app in Visual Studio 2017 that shows the following warning messages for every .js file in the project "(ESLint) Cannot find module 'eslint-config-react-app'...". 我们在Visual Studio 2017中有一个react应用程序,该应用程序为项目((ESLint)Cannot find module'eslint-config-react-app'...''中的每个.js文件显示以下警告消息。 We have the react-scripts package installed that pulled in the eslint-config-react-app package as well. 我们还安装了react-scripts软件包,该软件包也拉进了eslint-config-react-app软件包。 We have tried to install it ourselves in the local projects package.json as well as a global package. 我们尝试将其自己安装在本地项目package.json和全局包中。

No matter what we do these errors will not go away. 无论我们做什么,这些错误都不会消失。

UPDATED: The project folder structure is: 更新:项目文件夹结构为:

  • Project 项目
    • ClientApp ClientApp
      • public 上市
      • src src
      • packages.json packages.json
    • Controllers 控制器
    • Pages 页数

I have tried putting the following in the packages.json file: 我试过将以下内容放在packages.json文件中:

"eslintConfig": {
   "extends": "react-app"
}

I have tried creating a .eslintrc file in the ClientApp folder as well as moving to the project root folder so it sits at the same level as the ClientApp folder. 我尝试在ClientApp文件夹中创建一个.eslintrc文件,并将其移至项目根文件夹,以便它与ClientApp文件夹位于同一级别。 In the file I had the following: 在文件中,我有以下内容:

{
    "extends": "react-app"
}

I also tried the following in the .eslintrc file: 我还在.eslintrc文件中尝试了以下操作:

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ]
}

When I did this my error changes to " 当我这样做时,我的错误变为“

(ESLint) ESLint encountered a parsing error. (ESLint)ESLint遇到解析错误。

I found the solution. 我找到了解决方案。 I removed all .eslintrc files and also removed the ESLint config section of the packages.json file. 我删除了所有.eslintrc文件,还删除了packages.json文件的ESLint config部分。 Then I went into Tools...Options in Visual Studio and searched for ESLint. 然后我进入Visual Studio中的Tools ... Options并搜索ESLint。 I then clicked on the button "Reset global .eslintrc". 然后,我单击了按钮“重置全局.eslintrc”。 Finally I closed and re-opened the solution and everything is now working as expected. 最终,我关闭并重新打开了解决方案,现在一切正常。

This happened to me, but it was: 这发生在我身上,但是是:

Error: Failed to load plugin react: Cannot find module 'eslint-plugin-react'

I didn't have a .eslintrc in the website root!!! 我在网站根目录中没有.eslintrc !!! So I added one (there are lots of examples of what it must contain) 因此,我添加了一个(其中必须包含许多示例)

暂无
暂无

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

相关问题 Atom &amp; eslint:找不到模块 'eslint-config-react-app' - Atom & eslint: Cannot find module 'eslint-config-react-app' 无法加载在“package.json » eslint-config-react-app”中声明的插件“flowtype”:找不到模块“eslint/use-at-your-own-risk” - Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk' eslint-config-react-app 无效 属性“覆盖”是错误的类型 - eslint-config-react-app is invalid Property “overrides” is the wrong type create-react-app 版本 5 的“eslint-config-react-app”问题 - "eslint-config-react-app" issue with create-react-app version 5 插件“react”在“package.json » eslint-config-react-app 之间发生冲突 - Plugin "react" was conflicted between "package.json » eslint-config-react-app eslint-config-react-app throws找不到规则“ getter-return”的定义 - eslint-config-react-app throws Definition for rule 'getter-return' was not found ESLint 错误 - ESLint 找不到配置“react-app” - ESLint error - ESLint couldn't find the config "react-app" 部署 React 应用程序时出错,它一直在说 &lt;&lt; Plugin "react" was conflicted between "package.json » eslint-config-react-app » &gt;&gt; - Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >> 无法加载在 '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' 如何解决这个错误: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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM