Error: Unable to resolve module `react-native-gesture-handler`
我尝试在react-native中使用Navigation。
我添加了:
但是它给了我这样的错误:
错误:绑定失败:错误:无法从
eactnative\\proejectName\
ode_modules\\@react-navigation\
ative\\src\\Scrollables.js
不存在模块
这是索引:
1 2 3 4 5 | import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; AppRegistry.registerComponent(appName, () => App); |
这是app.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import React from 'react'; import { createStackNavigator, createAppContainer, } from 'react-navigation'; import First from './src/Components/First'; import DescriptionPage from './src/Components/DescriptionPage'; const Navigation = createStackNavigator({ First: { screen: First, }, DescriptionPage: { screen: DescriptionPage, }, }); const App = createAppContainer(Navigation); export default App; |
这是package.json:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | { "name":"ProjectName", "version":"0.0.1", "private": true, "scripts": { "start":"node node_modules/react-native/local-cli/cli.js start", "test":"jest" }, "dependencies": { "react":"16.8.3", "react-native":"0.59.1", "react-native-sqlite-storage":"^3.3.10", "react-navigation":"^3.5.1" }, "devDependencies": { "@babel/core":"7.4.0", "@babel/runtime":"7.4.2", "babel-jest":"24.5.0", "eslint-config-rallycoding":"^3.2.0", "jest":"24.5.0", "metro-react-native-babel-preset":"0.53.1", "react-test-renderer":"16.8.3" }, "jest": { "preset":"react-native" } } |
您还需要在项目依赖项列表中分别安装
希望这会有所帮助。祝您编码愉快!
使用以下命令安装
1 | yarn add react-native-gesture-handler |
,然后链接特定项目中的库
1 | react-native link react-native-gesture-handler |
在您的本机反应项目中找不到
Gesture Handler。运行此命令
1 | npm install react-native-gesture-handler |
快乐编码
在我的情况下,已安装
1:卸载
1 | npm uninstall react-native-gesture-handler --save |
2:安装
1 | npm install react-native-gesture-handler --save |
3:链接
1 | react-native link react-native-gesture-handler |
4:重新启动npm
1 | npm restart |
或
1 | npm start |
此处的新手:
1 | react-native-gesture-handler |
1 2 | import { createStackNavigator } from 'react-navigation-stack'; import {createAppContainer } from 'react-navigation'; |
如果您正在使用expo,则必须通过expo命令进行安装:
1 | expo install react-native-gesture-handler |
如果要升级到SDK39。
运行此命令:
1 | expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view |
谢谢。
有同样的问题。解决者:
1 2 3 | npm uninstall react-native-gesture-handler --save npm install react-native-gesture-handler --save |
正在工作
1 | "react-native-gesture-handler":"^1.8.0", |
使用它代替
1 | "react-native-gesture-handler":"1.8.0", |
删除^
使用以下命令安装
1 | yarn add react-native-gesture-handler |
对于React Native版本 我遇到了同样的问题,在我的情况下,react-native-gesture-handler本身的安装失败。我使用的是反应本机版本0.61.5。由于某些原因,我的项目未安装最新版本的react-native-gesture-handler。我通过安装特定版本的react-native-gesture-handler解决了该错误。 希望这会有所帮助。 如果您正在运行mac,请执行以下操作: 然后再次运行 确保您的反应导航版本为3.11.0。 然后