React Native:npm install上的警告

问题描述 投票:2回答:2

我正在使用react-navigation创建一个新的react native应用程序。

每次我做npm install --save react-navigation时,我都会看到一组与react-native-gesture-handler相关的警告。我正在使用react-native init Test创建一个全新的应用程序,下一步是安装react-navigation。

以下是警告和错误:

npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of jest-haste-map@^24.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of react-native-gesture-handler@^1.0.12 but none is installed. You must install peer dependencies yourself.

npm WARN [email protected] requires a peer of react-native-gesture-handler@^1.0.0 but none is installed. You must install peer dependencies yourself.

npm WARN @react-navigation/[email protected] requires a peer of react-native-gesture-handler@* but none is installed. You must install peer dependencies yourself.

在我的代码中导入库并在iOS模拟器上运行时,我收到如下错误:

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `react-native-gesture-handler` from `Documents/Code/Test/node_modules/@react-navigation/native/src/Scrollables.js`: Module `react-native-gesture-handler` does not exist in the Haste module map

我尝试在我的应用程序中删除node_modules文件夹并再次运行'npm install'和'npm install --save react-navigation',但这确实解决了这个问题。

请求建议。

node.js react-native npm react-navigation npm-install
2个回答
3
投票

创建新应用程序后,安装react-navigation库,然后您需要安装react-native-gesture-handler并链接库。

Step1 : react-native init test//your app name
Step2 : npm install --save react-navigation
Step3 : npm install --save react-native-gesture-handler
Step4 : react-native link react-native-gesture-handler

0
投票

我遵循了Brijesh的建议,还必须在我的Xcode项目中手动导入库。以下是我遵循的步骤:

Step1:react-native init test //你的应用名称

第2步:npm install --save react-navigation

第3步:npm install --save react-native-gesture-handler

Step4:react-native link react-native-gesture-handler

步骤5:右键单击Xco​​de中的库“将文件添加到项目”

Step6:/node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj

Step7:转到构建阶段并添加libRNGestureHandler.a

这解决了它。

© www.soinside.com 2019 - 2024. All rights reserved.