反应本机依赖

时间:2018-10-19 14:26:15

标签: reactjs react-native react-native-android expo native-base

我想开始在React-native中进行编程,并且遇到了一些问题:

-每当我跑步

 npm install -g react-native

获取此内容:

PS C:\Users\Name> npm install -g react-native
C:\Users\Name\AppData\Roaming\npm\react-native -> 
C:\Users\Name\AppData\Roaming\npm\node_modules\react-native\local- 
cli\wrong-react-native.js
npm WARN react-native@0.57.3 requires a peer of react@16.6.0-alpha.8af6728 
but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-check-constants@7.0.0-beta.38 requires a peer of 
@babel/core@7.0.0-beta.38 but none is installed. You must install peer 
dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 
(node_modules\react-native\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: 
{"os":"win32","arch":"x64"})

+ react-native@0.57.3
added 39 packages from 55 contributors, removed 20 packages and updated 82 
packages in 32.884s

但是,如果我手动安装这些软件包,它们仍然没有注册为已安装,并且出现了相同的错误消息。

-我遇到的第二个问题是博览会(我认为)。 我遵循了Facebook react nativegithub手册的说明,但是每当我尝试安装native-base软件包时,总会收到消息unable to resolve module native-base

我试图按照应该导致我解决清除监视程序和删除node_modules问题的步骤进行操作,但没有任何帮助。 由于同样的问题,我也无法实现react-native-swiper

每当我安装它们时,都会得到依赖项警告,但是当我安装依赖项时,警告不会消失。

如果我发出命令,似乎没有安装软件包。我以为可能是问题所在,但未能找到解决方案。

3 个答案:

答案 0 :(得分:2)

react-native不应作为全局安装。它应该安装在您的项目目录中。

我认为您打算安装react-native而不是react-native-cli 这为您提供了用于构建React-Native应用程序(例如react-native init)以启动项目等的cli选项。

通过使用react-native-cli模块,使用native-base模块变得更加容易,因为完成npm i -S native-base之后,您只需按照文档中的说明运行react-native link

答案 1 :(得分:0)

尝试删除您的node_modules文件夹并重新安装

npm我

您也可以尝试清理npm缓存。

编辑-更好的方法是安装create-react-native-app,该方法可以在盒子外面使用。 https://github.com/react-community/create-react-native-app

答案 2 :(得分:0)

尝试使用此命令npm install -g react-native-cli或sudo sudo npm install -g react-native-cli安装它。确保已在设备中安装了npm和节点