如何更新react-native-maps以适配create-react-native-app及指定依赖版本
The core issue here is that react-native-maps@0.21.0's peer dependencies don’t explicitly include react-native@0.55.x, which causes conflicts when using your target RN version. Here’s how to resolve this properly:
Recommended Approach: Upgrade to a Compatible Version (Permanent Fix)
Editing files in node_modules is a temporary band-aid that gets overwritten on future installs. Instead, use a version of react-native-maps that officially supports RN 0.55.2:
For Expo Users (Your Case)
Since your react-native-maps is a dependency of Expo, the cleanest fix is to upgrade your Expo SDK to a version that includes a compatible maps package:
- Expo SDK 27 (which pairs with RN 0.55.4) includes
react-native-maps@0.22.0—this version explicitly adds^0.55to its react-native peer dependencies. - Follow the official Expo SDK upgrade steps for your project type to update to SDK 27 or later.
For Non-Expo Users
If you installed react-native-maps directly, upgrade it to version 0.22.0 or later:
# Using npm npm install react-native-maps@0.22.0 --save # Using yarn yarn add react-native-maps@0.22.0
After installation, check the peerDependencies in the new react-native-maps/package.json—it should now list react-native: "^0.51 || ^0.52 || ^0.53 || ^0.54 || ^0.55".
Temporary Fix: Edit the Installed Package (If Upgrade Isn’t Possible)
If you can’t upgrade right now, modify the react-native-maps package.json to allow your RN version:
- Navigate to
node_modules/react-native-mapsin your project. - Open
package.jsonand adjust these sections:- Peer Dependencies (lines 81-82):
"peerDependencies": { "react": "^16.0", "react-native": "^0.51 || ^0.52 || ^0.53 || ^0.54 || ^0.55", // Add || ^0.55 "prop-types": "^15.0 || ^16.0" } - Dev Dependencies (lines 97-98):
"react": "^16.3.1", // Match your project's react version "react-native": "^0.55.2" // Match your project's RN version
- Peer Dependencies (lines 81-82):
- Run
npm installoryarn installagain to resolve remaining dependency warnings.
Why npm --depth 9999 update Caused Errors
That command tries to update every nested dependency in your project to the latest version, which almost always leads to conflicts—different packages require conflicting versions of the same dependency, so npm can’t resolve all of them. It’s not a recommended way to fix peer dependency issues.
Content of the question来源于stack exchange,提问作者DCR

