Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't npm install react-native not work?

I'm trying to install react-native through npm install --save react-native for my library so I can export a react component that uses View as a wrapper around it's children to be platform agnostic. When I try to import react-native it spews hundreds of lines saying that it can't resolve modules in react-native

eg

Error in ./~/react-native/Libraries/react-native/react-native.js Module not found: Error: Cannot resolve module 'ActivityIndicator'

What's the best way to resolve this?

like image 529
Trent Avatar asked Jul 03 '26 02:07

Trent


2 Answers

  1. You need to install react-native-cli first using npm install -g react-native-cli.
  2. Then start your project by hitting the following- react-native init YourProjectName

For detailed information, follow their guid!

like image 86
Mihir Avatar answered Jul 05 '26 16:07

Mihir


delete package-lock.json file and node modules folder, then npm install.

like image 37
Akshu Gautam Avatar answered Jul 05 '26 17:07

Akshu Gautam