-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLint: Error while loading rule 'react/display-name': Cannot find module 'react' #2329
Comments
Do you have react installed, in Specifically, by setting the version to "detect", you're forcing react to be installed so the plugin can detect its version. |
Yep, it's installed and located there. |
what's the path to package.json? in which dir are you running eslint? |
I've literally just discovered that this appears to only be an issue for this plugin (and only this plugin) with vscode-eslint only. Running eslint from the cli doesn't return the error, it only appears in the vscode ESLint extension. I've created an issue in the vscode-eslint repo so perhaps they'll discover the issue is on their end. |
Ah, gotcha - in that case I'd say it's an issue with vscode-eslint, probably not setting the require path correctly. eslint 6 requires fully resolved paths in places it didn't before, so this problem will likely crop up much more often for them. Closing this (and i'd suggest closing eslint/eslint#11891) in favor of microsoft/vscode-eslint#695. |
peerDependencies in the packages were throwing warnings, potentially related to yarnpkg/yarn#5810. In this commit, we rework the peerDependency definitions to align better with the conventions outlined in the main peerDependency documentation, and we define devDependencies both at the top level and at the package level, since package-level is technically closer to "correct" but it doesn't satisfy the checks in yarn yet. In addition, we've bumped a few versions and aligned across the packages where duplication occurs, which led to our tests running into jsx-eslint/eslint-plugin-react#2329 for our "detect" mode in eslint-plugin-react.
peerDependencies in the packages were throwing warnings, potentially related to yarnpkg/yarn#5810. In this commit, we rework the peerDependency definitions to align better with the conventions outlined in the main peerDependency documentation, and we define devDependencies both at the top level and at the package level, since package-level is technically closer to "correct" but it doesn't satisfy the checks in yarn yet. In addition, we've bumped a few versions and aligned across the packages where duplication occurs, which led to our tests running into jsx-eslint/eslint-plugin-react#2329 for our "detect" mode in eslint-plugin-react.
I'm having the same issue. It seems to be looking for the "react" module in the parent directory instead of the project root directory. Extremely frustrating |
Same problem here, without vscode. I am getting this from CLI. |
@MoOx is this also on windows? |
No macOS. |
Can you file a new issue? |
Happens for me too. I'm on Linux. This version works:
New versions are broken. |
If you're having this issue whilst using the ESLint VSCode extension, I was able to fix it by adding this to my VSCode settings.json:
|
Problem solved after update npm dependencies:
|
I have a custom config file, which can be found here:
For some reason when I attempt to use this custom config in a project, I get the following error:
The plugin is installed at
C:\Users\Me\Websites\Templates\core\node_modules\eslint-plugin-react
.This only occurs for this plugin. I don't have this issue with any other plugins I use. Everything appears to be setup correctly so I believe this is a bug with eslint-plugin-react.
The text was updated successfully, but these errors were encountered: