-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Error: Failed to load plugin 'prettier' declared in '.eslintrc.js » @react-native-community/eslint-config': Cannot find module 'eslint-plugin-prettier' Require stack: #32181
Comments
for me, with rn 0.64.2 and @react-native-community/[email protected] , when yarn install, i got the error:
when changing @react-native-community/eslint-config@^2.0.0, i got no errors. |
Can confirm that this is happening with both |
I should mention that running the linter by itself also throws this error (not just VSCode). ESLint: 7.32.0
ESLint couldn't find the plugin "eslint-plugin-prettier".
(The package "eslint-plugin-prettier" was not found when loaded as a Node module from the directory "/Users/kendallroth/Development/payme".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-prettier@latest --save-dev
The plugin "eslint-plugin-prettier" was referenced from the config file in ".eslintrc.js » @react-native-community/eslint-config" Installing as instructed/recommended that moves the error to a missing ESLint: 7.32.0
ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.
The config "prettier" was referenced from the config file in "/Users/kendallroth/Development/payme/node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js". Installing ESLint: 7.32.0
Error: .eslintrc.js » @react-native-community/eslint-config#overrides[2]:
Environment key "jest/globals" is unknown |
I was unable to "fix" this by downgrading to version |
I can verify that version |
Further digging revealed that this happened to me after as a side-effect of upgrading to Expo 43 (from 42). I'm trying to figure out which of the included package changes may have impacted the project. The only change made in that commit was a change to "dependencies": {
- "@react-native-masked-view/masked-view": "0.2.4",
+ "@react-native-masked-view/masked-view": "0.2.5",
"@react-navigation/native": "^6.0.2",
"@react-navigation/stack": "^6.0.7",
- "expo": "~42.0.1",
- "expo-linking": "~2.3.1",
- "expo-splash-screen": "~0.11.2",
- "expo-status-bar": "~1.0.4",
- "react": "16.13.1",
- "react-dom": "16.13.1",
- "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
+ "expo": "^43.0.0",
+ "expo-linking": "~2.4.2",
+ "expo-splash-screen": "~0.13.4",
+ "expo-status-bar": "~1.1.0",
+ "react": "17.0.1",
+ "react-dom": "17.0.1",
+ "react-native": "0.64.2",
"react-native-gesture-handler": "~1.10.2",
- "react-native-screens": "~3.4.0",
+ "react-native-safe-area-context": "3.3.2",
+ "react-native-screens": "~3.8.0",
"react-native-vector-icons": "^8.1.0",
- "react-native-web": "~0.13.12"
+ "react-native-web": "0.17.1"
},
"devDependencies": {
- "@babel/core": "^7.9.0",
+ "@babel/core": "^7.12.9",
"@react-native-community/eslint-config": "^3.0.0",
- "@types/react": "~16.9.35",
- "@types/react-native": "~0.63.2",
+ "@types/react": "~17.0.21",
+ "@types/react-native": "~0.64.12",
"eslint": "^7.32.0",
"prettier": "^2.3.2",
- "typescript": "~4.0.0"
+ "typescript": "~4.3.5"
}
}, |
This is proving to be quite frustrating, as my linting has stopped working entirely in VSCode (and CLI/tests). I will try to create a replica on a new project (from Expo) but would be very curious if anyone would have any ideas about this (can share original project if needed). |
Created a minimum test case that illustrates the issue, but for the life of me cannot figure out what is going wrong.
{
"name": "react-native-eslint-plugin-test",
"version": "0.1.0",
"scripts": {
"lint": "eslint ."
},
"dependencies": {
"expo": "~43.0.0",
"expo-status-bar": "~1.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.2",
"react-native-web": "0.17.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@react-native-community/eslint-config": "^3.0.0",
"@types/react": "~17.0.21",
"@types/react-native": "~0.64.12",
"eslint": "^7.32.0",
"prettier": "^2.4.1",
"typescript": "~4.3.5"
},
"private": true
}
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
extends: [
"@react-native-community",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
// Disable ESLint rules that would conflict with Prettier
"prettier",
"plugin:prettier/recommended",
],
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-console": "warn",
"prettier/prettier": "warn",
"prefer-const": "warn",
"react/display-name": "off",
},
}; Error: > eslint .
Oops! Something went wrong! :(
ESLint: 7.32.0
ESLint couldn't find the plugin "eslint-plugin-prettier".
(The package "eslint-plugin-prettier" was not found when loaded as a Node module from the directory "/Users/kendallroth/Development/eslint-copy-test".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-prettier@latest --save-dev
The plugin "eslint-plugin-prettier" was referenced from the config file in ".eslintrc.js » @react-native-community/eslint-config".
|
Ooookay, so to add to the confusion, I tried running the exact setup from # Install dependencies
> npm install --save-dev eslint prettier @react-native-community/eslint-config
# Create ESLint file and copy in from NPM page
> touch .eslintrc
# Create simple TypeScript file with some to be caught by linter
> touch index.ts
# Add ESLint script and run
> npm run lint For some unknown reason, this succeeded on Windows WSL2/Ubuntu, but failed on Mac! Exact same commands...everything 😱! At this point I am probably going to have to replace this package with the underlying packages, unless anyone has some ideas on why this is different between Linux and Mac. Also curious if anyone else can replicate this issue with the above workflow? |
i had the same probleme. i think there is a trouble with the path of dependency of this package. i fixed it by installing those and his dependencies manually : try to install the same version of packages, you can use npm ls <package_name> to get the version. and npm install -D <package_name>@ to install specific version. don't forget to delete package.lock and node_modules if you have some troubles. and don't forget to restart vscode after package installation to allow eslint server to restart. |
I got the same error after upgrading a project from Node.js 14.18.1 to version 16.13.0. No other changes were made. Installing the aforementioned packages manually fixed the problem. |
For those using This is probably happening due to duplicate copies of certain libraries. |
I have downgraded node from 16.13.0 to 14.18.1 to fix the issue. Do you think it's better to manually install all the missing packages instead? (both are just a workaround for the broken default react-native project init on Mac) |
Looks like this is related to #32528. Try downgrading ESLint to v7, it fixed the issue for me.
|
Hi, this might be unrelated, but I noticed something after moving from React Native 0.63 to 0.66 all the red lines and auto-formatting I get from Prettier suddenly disappeared, how can I get them back? I use VS Code and they really helped me keep my code organised. |
The package isn't found because it is placed underneath @react-native-community/eslint-config instead of the root node_modules. don't know why |
Using yarn install instead of npm fixed the issue for me.... |
I'm using yarn but it didn't work, what I don't understand is that when using the default project created by react native cli it works |
as @SimonChaumet stated: "the package isn't found because it is placed underneath For instance, a faulty
The first line (v2.1.2) comes from To make sure that only 1 version is installed:
|
I think it's all caused by peer dependency in npm >=7.
Article about dependencies: |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
After installing react-native with npx it throws an error on me with eslint settings in webstorm.
Description
I have tried installing prettier on it's own but it didn't worked
React Native version: 0.65.1
Run
react-native info
in your terminal and copy the results here.info Fetching system and libraries information...
System:
OS: macOS 11.5.2
CPU: (8) arm64 Apple M1
Memory: 179.45 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.8.0 - /opt/homebrew/bin/node
Yarn: Not Found
npm: 7.21.0 - /opt/homebrew/bin/npm
Watchman: 2021.08.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: Arctic Fox 2020.3.1 Patch 2 Arctic Fox 2020.3.1 Patch 2
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.65.1 => 0.65.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
Expected Results
Describe what you expected to happen.
no errors is shown
Snack, code example, screenshot, or link to a repository:
I haven't changed anything from the app created with npx
The text was updated successfully, but these errors were encountered: