I moved from npm to yarn and for some reason, although I imported the react-native library it doesn't recognize it, I get the error:
./src/App.js
Module not found: Can't resolve 'react-native' in '/var/react-projects/gymgains/src'
I delete the package.json.lock, also yarn.lock and tried again:
yarn
Yet it didn't solve the problem.
Here is my package.json:
{
"name": "App",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-firebase-file-uploader": "^2.4.2",
"react-native": "^0.58.5",
"react-native-cli": "^2.0.1",
"react-scripts": "2.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
And here is my import statements:
import React, { Component } from 'react';
import firebase from 'firebase';
import { Text, View, Image } from 'react-native';
import 'firebase/firestore';
import FileUploader from 'react-firebase-file-uploader';
Is there a difference between running it with 'yarn start' to see it in the browser and push it to an Android to test it in the simulator, could that be the problem that react-native does not work in the web browser? Any idea how to solve this issue?
Thanks
I had some very similar issue:
Module not found: Can't resolve 'react-native'
and in my case it helped me to do
yarn add react-native-web
As you do not have that module installed. You could give it a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With