我想开始在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 native
上github
手册的说明,但是每当我尝试安装native-base
软件包时,总会收到消息unable to resolve module native-base
。
我试图按照应该导致我解决清除监视程序和删除node_modules问题的步骤进行操作,但没有任何帮助。
由于同样的问题,我也无法实现react-native-swiper
。
每当我安装它们时,都会得到依赖项警告,但是当我安装依赖项时,警告不会消失。
如果我发出命令,似乎没有安装软件包。我以为可能是问题所在,但未能找到解决方案。
答案 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和节点