绑定失败:错误:无法从App.js
解析模块react-navigation-stack
:未能在项目中找到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"
}
}
App.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);
4条答案
按热度按时间7gs2gvoe1#
您的
package.json
没有要使用的模块。您需要安装模块。或
rqdpfwrv2#
有关https://github.com/react-navigation/react-navigation/releases/tag/v4.0.0的升级说明,请参阅发行说明
owfi6suc3#
ie3xauqp4#
可能不是每个人的答案。我也有同样的问题,但我只需要重建项目并运行。