node.js - 将 Expo 升级到 SDK 40,解决 undefined@undefined 时无法安装包

标签 node.js react-native npm expo

我现在使用的是 Expo SDK 37,需要更新到目标 Android 29。在我运行 expo upgrade、删除 Node 模块并运行 npm install 后,我得到了这个:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native@0.63.2
npm ERR! node_modules/react-native
npm ERR!   react-native@"https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.49.1" from react-native-deck-swiper@1.6.7
npm ERR! node_modules/react-native-deck-swiper
npm ERR!   react-native-deck-swiper@"^1.6.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

所以我无法安装我的包。我不确定解析 undefined@undefined 是什么意思。如何修复这些错误?

我的 package.json 看起来像这样:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-community/datetimepicker": "3.0.4",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-firebase/app": "^8.4.7",
    "@react-navigation/bottom-tabs": "^5.6.0",
    "@react-navigation/native": "^5.6.0",
    "@react-navigation/stack": "^5.7.0",
    "base-64": "^0.1.0",
    "css-tree": "^1.1.2",
    "expo": "^40.0.0",
    "expo-ads-admob": "~8.4.0",
    "expo-cli": "^4.0.4",
    "expo-font": "~8.4.0",
    "expo-updates": "~0.4.1",
    "expo-web-browser": "~8.6.0",
    "firebase": "7.9.0",
    "formik": "^2.1.5",
    "imagemagick": "^0.1.3",
    "lodash": "^4.17.20",
    "react": "16.13.1",
    "react-circular-progressbar": "^2.0.3",
    "react-datepicker": "^3.1.3",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-circular-progress": "^1.3.6",
    "react-native-circular-progress-patch": "0.0.2",
    "react-native-code-push": "^6.3.0",
    "react-native-collapsible": "^1.5.3",
    "react-native-datepicker": "^1.7.2",
    "react-native-deck-swiper": "^1.6.7",
    "react-native-dropdown-picker": "^3.6.8",
    "react-native-dynamic-deck-swiper": "0.0.8",
    "react-native-gesture-handler": "~1.8.0",
    "react-native-reanimated": "~1.13.0",
    "react-native-safe-area-context": "3.1.9",
    "react-native-safe-area-view": "^1.1.1",
    "react-native-screens": "~2.15.2",
    "react-native-svg": "12.1.0",
    "react-native-swiper": "^1.6.0-rc.3",
    "react-native-view-overflow": "0.0.5",
    "react-native-web": "~0.13.12",
    "react-navigation": "^4.3.9",
    "react-navigation-stack": "^2.7.0",
    "react-redux": "^7.2.2",
    "react-redux-firebase": "^3.0.0",
    "redux": "^4.0.5",
    "redux-firestore": "^0.13.0",
    "redux-thunk": "^2.3.0",
    "yup": "^0.29.3"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "babel-preset-expo": "8.3.0"
  },
  "private": true
}

最佳答案

看起来您正在使用 npm 7。npm 7 于 2020 年 10 月发布,并围绕 peerDependencies 的行为引入了重大更改,因此它不适用于之前发布的 Node 生态系统中的许多项目。我建议使用 npm 6 或 yarn classic。

关于node.js - 将 Expo 升级到 SDK 40,解决 undefined@undefined 时无法安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66282710/

相关文章:

javascript - 如何将数据传递给 http 创建服务器回调?

node.js - 为什么由于 Node.js 中的可执行路径无效而导致 try-catch block 无法捕获 child_process 生成异常?

react-native - react native : Android: Different border colors with borderRadius

reactjs - 将 native 代码与 react native 混合

typescript - 在 Angular2 项目中使用 TweenMax

node.js - 类型不可分配给 express-jwt 中的类型 'GetVerificationKey'。(使用 auth0)

node.js - (Express js 4 Multer) 在文件上传之前检查表单字段(如果为空)

android - React Native - 为什么我们在 CameraRoll.getPhotos() 中使用 after 属性?

node.js - 无法在 electron-forge 中使用 electron-packager 构建

node.js - 语法错误 : Unexpected reserved word => prettier/third-party. js