简体   繁体   English

反应本机依赖

[英]React Native dependencies

I want to start programming in React-native and have few problems: 我想开始使用React-native编程,并且有几个问题:

-Whenever I run -每当我跑步

 npm install -g react-native

get this: 得到这个:

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

However, if I manually install these packages, they still don't register as installed and I am getting the same error messages. 但是,如果我手动安装这些软件包,它们仍然不会注册为已安装,并且会出现相同的错误消息。

-The second problem I come across is, with expo (I think). -我遇到的第二个问题是博览会(我认为)。 I have followed the instructions of the react native manual on facebook's github , but whenever I try to install native-base package, always get the message unable to resolve module native-base . 我已经遵循了Facebook githubreact native手册的指示,但是每当我尝试安装native-base软件包时,总会收到unable to resolve module native-base的消息。

I tried to follow the steps that should lead me to solving the problem of clearing watchman and deleting node_modules but nothing helped. 我试图按照应该引导我解决清除守卫和删除node_modules问题的步骤进行操作,但没有任何帮助。 I also couldn't implement react-native-swiper because of the same problem. 由于同样的问题,我也无法实现react-native-swiper

Whenever I install them, get the dependencies Warnings but when I install the dependencies the warnings don't go away. 每当我安装它们时,都获得依赖项警告,但是当我安装依赖项时,警告不会消失。

It seems that the packages don't get installed if I issue the command. 如果我发出命令,似乎没有安装软件包。 I thought that could be the problem but haven't been able to find a resolution to that. 我以为可能是问题所在,但未能找到解决方案。

react-native should not be installed as global. react-native不应安装为全局。 It should be installed in your project directory. 它应该安装在您的项目目录中。

I think that instead of react-native you meant to install react-native-cli which gives you cli options for building React-Native apps such as react-native init to start a project etc. 我认为与其react-native你的意思是安装react-native-cli ,让你CLI选项建筑阵营原生应用程序,如react-native init启动项目等。

By using the react-native-cli module, using the native-base module becomes much easier as after doing npm i -S native-base you have to just run react-native link as written in the documentation. 通过使用react-native-cli模块,使用native-base模块变得容易得多,因为在执行npm i -S native-base您只需按照文档中的说明运行react-native link

Try delete your node_modules folder and re-install 尝试删除您的node_modules文件夹并重新安装

npm i

You can also try clean npm cache. 您也可以尝试清理npm缓存。

Edit - better way will be install create-react-native-app, that should works outside the box. 编辑-更好的方法是安装create-react-native-app,该方法应在框外运行。 https://github.com/react-community/create-react-native-app https://github.com/react-community/create-react-native-app

Try to install it with this command npm install -g react-native-cli or with the sudo sudo npm install -g react-native-cli . 尝试使用此命令npm install -g react-native-cli或sudo sudo npm install -g react-native-cli Make sure you have installed the npm and node in your device 确保已在设备中安装了npm和节点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM