无法解析“ App.js”中的“ @ react-navigation / stack”

时间:2020-07-14 19:08:43

标签: javascript reactjs react-native

我第一次尝试本机操作并尝试创建堆栈导航,但出现以下错误:

Unable to resolve "@react-navigation/stack" from "App.js"

这是mu 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": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.7.0",
    "expo": "~38.0.8",
    "expo-status-bar": "^1.0.2",
    "react": "~16.11.0",
    "react-dom": "~16.11.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.0.7",
    "react-native-screens": "^2.9.0",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.4.0",
    "react-navigation/stack@": "^5.7.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",
    "babel-preset-expo": "~8.1.0"
  },
  "private": true
}

我正在使用expo cli启动我的应用程序。

1 个答案:

答案 0 :(得分:1)

您已安装react-navigation/stack@,并正在尝试导入@react-navigation/stack

删除react-navigation/stack@,因为它不是正确的导入,然后将@react-navigation/stacknpm install --save @react-navigation/stack一起安装。