vscode-eslint: Failed to load plugin 'react' declared in 'react1/.eslintrc.js': Cannot find module 'eslint-plugin-react'
[Info - 7:07:59 PM] ESLint server stopped. [Info - 7:07:59 PM] ESLint server running in node v10.11.0 [Info - 7:08:00 PM] ESLint server is running. [Info - 7:08:00 PM] ESLint library loaded from: /Users/wubin02/work/react1/node_modules/eslint/lib/api.js [Error - 7:08:01 PM] Failed to load plugin ‘react’ declared in ‘react1/.eslintrc.js’: Cannot find module ‘eslint-plugin-react’ Require stack:
- /Users/wubin02/work/placeholder.js Happened while validating /Users/wubin02/work/react1/src/test.js This can happen for a couple of reasons:
- The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
- If ESLint is installed globally, then make sure ‘eslint-plugin-react’ is installed globally as well.
- If ESLint is installed locally, then ‘eslint-plugin-react’ isn’t installed correctly.
Consider running eslint --debug /Users/wubin02/work/react1/src/test.js from a terminal to obtain a trace about the configuration files used.
but when I exec ./node_modules/.bin/eslint --debug /Users/wubin02/work/react1/src/test.js is ok; I tried many methods, finally I got a method , set workingDirectories as below:
{
"folders": [
{
"path": "/Users/wubin02/work/react1"
}
],
"settings": {}
}
if there are many projects , you can add extra path as below:
{
"folders": [
{
"path": "/Users/wubin02/work/react1"
},
{
"path": "/Users/wubin02/work/proj1"
},
{
"path": "/Users/wubin02/work/proj2"
}
],
"settings": {}
}
is there any solution ?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (3 by maintainers)
@dbaeumer Oh, I think I found my problem: my workspace contains both my server and my client, with a
eslintrc.json
for each. When I open VsCode with only my client, it works fine. Adding both folders to my workspace as multiple roots works too. So, sorry but I think my issue is not related to the original one, but thanks for leading me to the solution!Specifying working directory solved the problem for me
I’m having the same problem
For me this issue occurs when I add a few projects to workspace, but this projects has one common root folder, like on the screen
And every of this projects (Project-1 and Project-2) has it’s own eslint config etc. This is independents projects but combined in workspace within one root folder (MyProjects).
If I add (Project-1 and Project-2) to workspace without root folder like this , then elsint v6, works as expected.
@mateusbds Well, I think I know what’s going on: VsCode looks for
eslintrc.json
in your working directory. It founds one that does not contains react plugin, so it issues an error. In my project, I don’t have exactly the same file tree as yours: my server and my client are both on the same level and there is aeslintrc.json
at the root directory and in the client. What I did is simply move the root file to the server directory and open my workspace with two folders : my client and my server. What I think you can do as a workaround (although I tested only the last one, so I don’t know if the others would work):eslintrc.json
file (nearest in directory levels)eslintrc.json
and add react plugin so it covers both server and clienteslintrc.json
. Then use a multi-root workspace into VsCode.