[英](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: 更新:项目文件夹结构为:
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.