如何将依赖项导入React Native Project?

时间:2019-03-22 15:57:52

标签: 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

0 个答案:

没有答案