克隆React Native项目后yarn遇peer依赖警告及自动提示消失求助
Hey there! Let's break down your issues step by step—these are common hurdles when working with older React Native projects, so we'll tackle them one by one.
1. Understanding & Fixing Peer Dependency Warnings
First, let's look at the warnings you saw after running cd /path/to/project/ && yarn:
warning " > react-native-looped-carousel@0.1.13" has incorrect peer dependency "react-native@^0.54.0". warning " > react-navigation-stack@1.10.3" has incorrect peer dependency "react-native-screens@^1.0.0 || ^1.0.0-alpha". warning " > @react-native-community/eslint-config@0.0.5" has unmet peer dependency "eslint@>=5". warning "@react-native-community/eslint-config > eslint-plugin-react@7.12.4" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0". warning "@react-native-community/eslint-config > eslint-plugin-eslint-comments@3.1.2" has unmet peer dependency "eslint@>=4.19.1". warning "@react-native-community/eslint-config > babel-eslint@10.0.1" has unmet peer dependency "eslint@>= 4.12.1". warning "@react-native-community/eslint-config > eslint-plugin-flowtype@2.50.3" has unmet peer dependency "eslint@>=2.0.0". warning "@react-native-community/eslint-config > eslint-plugin-jest@22.4.1" has unmet peer dependency "eslint@>=5". warning "@react-native-community/eslint-config > eslint-plugin-react-hooks@1.7.0" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0". warning "@react-native-community/eslint-config > eslint-plugin-react-native@3.6.0" has unmet peer dependency "eslint@^3.17.0 || ^4 || ^5". warning "@react-native-community/eslint-config > @typescript-eslint/eslint-plugin@1.13.0" has unmet peer dependency "eslint@^5.0.0". warning "@react-native-community/eslint-config > @typescript-eslint/parser@1.13.0" has unmet peer dependency "eslint@^5.0.0". warning "@react-native-community/eslint-config > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta". warning "@react-native-community/eslint-config > @typescript-eslint/eslint-plugin > @typescript-eslint/experimental-utils@1.13.0" has unmet peer dependency "eslint@*".
These warnings pop up because packages declare "peer dependencies"—specific versions of other tools they need to work correctly. Your project's current dependency versions don't match those expectations. Here's how to fix them:
Fix for ESLint-related warnings
Most of your warnings tie back to @react-native-community/eslint-config@0.0.5 requiring eslint@>=5. Your project likely has an ESLint version that's either too old or too new. Fix this by installing a compatible version:
yarn add eslint@5.16.0 --dev
This will satisfy all ESLint-related peer requirements from sub-packages like eslint-plugin-react and @typescript-eslint/eslint-plugin.
Fix for react-native-looped-carousel & react-navigation-stack
- react-native-looped-carousel@0.1.13: This is a very outdated package (last updated in 2018) built for React Native 0.54.0. You have two options:
- Swap it for a maintained alternative like
react-native-snap-carousel(actively updated and compatible with modern RN versions) - Temporarily ignore the warning with
yarn install --ignore-peer-deps(note: this might cause unexpected bugs if the package doesn't play nice with your RN version)
- Swap it for a maintained alternative like
- react-navigation-stack@1.10.3: It needs
react-native-screens@^1.0.0. Install a compatible version:
If you don't want to useyarn add react-native-screens@1.0.0-alpha.23 --devreact-native-screens, you can disable it in your navigation config by addinguseScreens(false)(check the react-navigation-stack docs for exact setup steps).
2. Fixing the Missing Autocomplete Feature
Your autocomplete disappearing is almost certainly linked to incomplete or mismatched dependencies—editor language services rely on properly installed tools like ESLint and TypeScript to work. Try these steps:
- First, fix the peer dependency issues above: This ensures all tools powering autocomplete are set up correctly.
- Restart your editor: Editors often cache dependency state; closing and reopening it can refresh the language service.
- Check editor plugins: Make sure you have React Native-specific plugins installed (like VS Code's React Native Tools) and enabled.
- Verify project configuration:
- For TypeScript projects, check
tsconfig.jsonto ensure theincludearray covers your source files (e.g.,"include": ["src/**/*", "*.ts", "*.tsx"]). - For JavaScript projects, add a
jsconfig.jsonfile in your project root:{ "compilerOptions": { "target": "es6", "module": "commonjs", "allowSyntheticDefaultImports": true }, "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"] }
- For TypeScript projects, check
- Reinstall dependencies with a clean cache:
This clears any corrupted cached packages that might be causing issues.yarn cache clean yarn install
内容的提问来源于stack exchange,提问作者Pratap Sharma

