React Native dependencies

Niyu picture Niyu · Oct 19, 2018 · Viewed 8.2k times · Source

I want to start programming in React-native and have few problems:

-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 [email protected] requires a peer of [email protected] 
but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of 
@babel/[email protected] but none is installed. You must install peer 
dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] 
(node_modules\react-native\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
[email protected]: wanted {"os":"darwin","arch":"any"} (current: 
{"os":"win32","arch":"x64"})

+ [email protected]
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.

I tried to follow the steps that should lead me to solving the problem of clearing watchman and deleting node_modules but nothing helped. I also couldn't implement react-native-swiper because of the same problem.

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.

Answer

Ashniu123 picture Ashniu123 · Oct 19, 2018

react-native should not be installed as global. 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.

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.