You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用create-react-native-app遇npm依赖错误,修复后仍有问题求指导

Hey there, let's work through these dependency headaches you're hitting with create-react-native-app. I've dealt with similar messes before, so let's break this down step by step.

First, let's recap the errors you ran into:

Initial Dependency Errors

npm ERR! peer dep missing: react@16.3.1, required by react-native@0.55.4 
npm ERR! extraneous: websql@0.4.4 d:\atestbed\native-react\lecture4-contacts\node_modules\websql 
npm ERR! missing: websql@https://github.com/expo/node-websql/archive/18.0.0.tar.gz, required by expo@27.0.1 
npm ERR! peer dep missing: react-native@^0.51 || ^0.52 || ^0.53 || ^0.54, required by react-native-maps@0.21.0 
npm ERR! peer dep missing: eslint@^3.17.0 || ^4.0.0, required by eslint-plugin-react-native@3.2.1 

Follow-Up Errors After Partial Fixes

npm ERR! peer dep missing: react-native@^0.51 || ^0.52 || ^0.53 || ^0.54, required by react-native-maps@0.21.0 
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.10.0 
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1 
npm ERR! missing: safe-buffer@5.1.1, required by readable-stream@2.3.6 
npm ERR! missing: safe-buffer@5.1.1, required by string_decoder@1.1.1 
npm ERR! missing: string-width@1.0.2, required by gauge@2.7.4 
npm ERR! missing: strip-ansi@3.0.1, required by gauge@2.7.4 
npm ERR! missing: strip-ansi@3.0.1, required by string-width@1.0.2 
npm ERR! missing: ansi-regex@2.1.1, required by strip-ansi@3.0.1 
npm ERR! missing: string-width@1.0.2, required by wide-align@1.1.2 
npm ERR! missing: once@1.4.0, required by glob@7.1.2 
npm ERR! missing: once@1.4.0, required by inflight@1.0.6 
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6 
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0 
npm ERR! missing: minipass@2.2.4, required by tar@4.4.1 
npm ERR! missing: mkdirp@0.5.1, required by tar@4.4.1 
npm ERR! missing: safe-buffer@5.1.1, required by tar@4.4.1 
npm ERR! missing: yallist@3.0.2, required by tar@4.4.1 
npm ERR! missing: minipass@2.2.4, required by fs-minipass@1.2.5 
npm ERR! missing: safe-buffer@5.1.1, required by minipass@2.2.4 
npm ERR! missing: yallist@3.0.2, required by minipass@2.2.4 
npm ERR! missing: minipass@2.2.4, required by minizlib@1.1.0 
First: What Do These Errors Actually Mean?

Let's decode the error types to understand the root issues:

  • Peer dep missing: These are dependencies a package expects your project to have at a specific version (e.g., react-native@0.55.4 needs react@16.3.1, react-native-maps@0.21.0 only works with older react-native versions).
  • Extraneous: A package is installed but not listed in your package.json (like websql@0.4.4 here—this is likely a leftover from a bad install).
  • Missing nested dependencies: These are small, underlying packages that failed to install properly, usually caused by corrupted node_modules or a broken npm cache.
Should You Wait for Updates or Fix This Now?

Short answer: Most of these need fixing immediately—waiting for upstream updates won't resolve local installation corruption or version mismatches. Here's why:

  • Peer dependency conflicts will break core functionality (like expo/react-native integration) and won't fix themselves unless you align package versions intentionally.
  • Missing nested dependencies are almost always local issues, not problems with the packages themselves. Updates can't fix a corrupted node_modules folder.
  • The only exception would be if a package has a known peer dependency bug that's already fixed in a newer version—but you'd still need to update that package manually.
Step-by-Step Fixes to Resolve These Issues

Let's tackle this systematically:

1. Clean Up Corrupted Installs First

The long list of missing nested dependencies is a clear sign your local setup is messed up. Let's wipe the slate clean:

# Delete node_modules and lock files
rm -rf node_modules package-lock.json
# Clear npm cache
npm cache clean --force

# If you're using yarn instead, run these:
rm -rf node_modules yarn.lock
yarn cache clean

2. Fix Peer Dependency Mismatches

Sync React/React-Native/Expo Versions

You saw conflicts between react@16.3.2 and expo@27.0.1—expo@27 is locked to react@16.3.1, so stick with that version. Update your package.json to have these exact versions:

"react": "16.3.1",
"react-native": "0.55.4",
"expo": "27.0.1"

Fix React-Native-Maps Compatibility

react-native-maps@0.21.0 doesn't support your react-native@0.55.4 version. You have two safe options:

  • Update react-native-maps to a version that supports react-native 0.55.x (version 0.22.0+ works):
    npm install react-native-maps@^0.22.0 --save
    
  • If you need to stay on 0.21.0, use npm install --force to ignore the peer warning (only do this if you've confirmed the package works with your react-native version).

3. Install the Correct Websql Dependency

Expo@27.0.1 requires a specific fork of websql. Install it directly using the URL from your error:

npm install https://github.com/expo/node-websql/archive/18.0.0.tar.gz --save

4. Reinstall Dependencies Properly

After cleaning up and aligning versions, reinstall your dependencies:

# With npm
npm install

# Or with yarn (recommended for more reliable installs)
yarn install

5. Remove Extraneous Packages

The websql@0.4.4 extraneous error should disappear once you install the expo-specific version. If it doesn't, uninstall it manually:

npm uninstall websql@0.4.4

6. Fix ESLint Peer Dependency

For the eslint error, install a compatible version of eslint:

npm install eslint@^4.0.0 --save-dev
Final Check

After completing these steps, run npm ls again to verify all errors are gone. If you still see peer warnings, double-check that all your packages match expo's version compatibility guidelines (expo's docs have a handy reference for this).

内容的提问来源于stack exchange,提问作者DCR

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:31:22