react-native - 如何将依赖项导入 React Native 项目?
问题描述
我在向我的 React (Native) 项目添加依赖项时遇到问题。我正在尝试使用createBottomMaterialNavigator
,文档说它需要一个特定的库并说要安装它:npm install react-navigation-material-bottom-tabs react-native-paper
我已经运行了它,并且还使用npm install --save ...etc
. 首先,我没有在package.json
我希望看到新库出现的文件中看到任何变化,对吧?
当我添加import { createMaterialBottomTabNavigator } from "react-navigation-material-bottom-tabs";
到我的项目时,我收到一个模块不存在的错误。(这确实有道理)
谁能帮我弄清楚我做错了什么?
更新:我试过 npm 链接,没有运气:
sudo npm link react-navigation-material-bottom-tabs react-native-paper
Password:
npm WARN react-navigation-material-bottom-tabs@1.0.0 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-material-bottom-tabs@1.0.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-material-bottom-tabs@1.0.0 requires a peer of react-native-paper@^2.2.2 but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-material-bottom-tabs@1.0.0 requires a peer of react-navigation@>=2.0 || ^2.0.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-tabs@1.0.0 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-tabs@1.0.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-tabs@1.0.0 requires a peer of react-native-screens@^1.0.0 || ^1.0.0-alpha but none is installed. You must install peer dependencies yourself.
npm WARN react-native-tab-view@1.3.4 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-tab-view@1.3.4 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
+ react-navigation-material-bottom-tabs@1.0.0
added 10 packages from 5 contributors in 1.023s
/Users/TuzMacbookPro2017/Library/Mobile Documents/com~apple~CloudDocs/Development/QMG/Learning/Tuz1App/node_modules/react-navigation-material-bottom-tabs -> /usr/local/lib/node_modules/react-navigation-material-bottom-tabs
> fsevents@1.2.7 install /usr/local/lib/node_modules/react-native-paper/node_modules/fsevents
> node install
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.7 and node@11.12.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/react-native-paper/node_modules/fsevents
gyp ERR! node -v v11.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:988:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/react-native-paper/node_modules/fsevents
node-pre-gyp ERR! node -v v11.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/react-native-paper/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
npm WARN react-native-paper@2.14.0 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-paper@2.14.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-paper@2.14.0 requires a peer of react-native-vector-icons@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-safe-area-view@0.12.0 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-safe-area-view@0.12.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN create-react-context@0.2.3 requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @callstack/react-theme-provider@1.0.7 requires a peer of react@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/react-native-paper/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ react-native-paper@2.14.0
added 231 packages from 217 contributors in 9.078s
npm ERR! Link target resolves to the same directory as link source: /usr/local/lib/node_modules/react-native-paper
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/TuzMacbookPro2017/.npm/_logs/2019-03-22T16_09_34_044Z-debug.log
解决方案
推荐阅读
- android - 如何展示导航抽屉?
- matlab - 如何制作一个包含航班号、开始索引和结束索引的 3 列矩阵
- elasticsearch - 在 Elastic Watchers 的松弛通知中清除警报时已解决的警报
- menu - Electron:如何从渲染过程中填充菜单?
- kubernetes - 如何在 kubernetes/istio 上设置 ssl 证书,以便我的站点可以使用 https 访问它?
- sql-server - SQL Server DateTime 列中的年份部分更新
- curl - 如何通过 curl 访问具有 Okta 身份验证的应用程序?
- reactjs - 如何在 React Native App 中编写乌尔都语
- rust - 如何处理包含在 Rc 中的新型枚举的模式匹配
>? - c - 仅使用递归执行此操作