gpt4 book ai didi

react-native - 我无法使用 react 导航 v4 解决此捆绑错误

转载 作者:行者123 更新时间:2023-12-03 22:53:20 25 4
gpt4 key购买 nike

捆绑失败:错误:无法解析模块 react-navigation-stack来自 App.js : 在项目中找不到 react-navigation-stack。

我尝试删除节点模块并重新安装它们,清除缓存,在新的新项目中尝试相同但没有结果

包.json 文件

{
"name": "navigator",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.2",
"react-native-gesture-handler": "^1.4.1",
"react-native-reanimated": "^1.3.0",
"react-native-screens": "1.0.0-alpha.23",
"react-navigation": "^4.0.10"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}

应用程序.js

    import React from 'react';
import { View, Text } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import HomeScreen from './src/screens/HomeScreen';
import ComponentScreen from './src/screens/ComponentScreen';


const navigator = createStackNavigator(
{
Home: HomeScreen
},
{
initialRouteName: 'Home',
defaultNavigationOptions: {
title: 'App'
}
}
);

export default createAppContainer(navigator);

最佳答案

您的 package.json没有您要使用的模块。您需要安装一个模块。

yarn add react-navigation-stack

或者
npm install react-navigation-stack

关于react-native - 我无法使用 react 导航 v4 解决此捆绑错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58254850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com