Trying to build a create-react-app project with expo, throws error about react-native - reactjs

I've created my react app using create-react-app, and was trying to use expo, but its throwing errors when I try and build it using expo build:android:
Error: Can't find react-native in package.json dependencies
Error: React Native is not installed. Please run `npm install` in your project directory.
Do I need to start over with a react-native project, or is there a way to continue on and get this project published?

I suggest you create your project using the expo docs :
npm install expo-cli --global
expo init my-new-project
cd my-new-project
expo start

Try this:
Remove node_modules folder.
run "yarn install".
run "expo start".
This looks like a similar issue on this github error
https://github.com/expo/expo-cli/issues/248

Related

react native navigation TypeError: null is not an object (evaluating '_RNGestureHandlerModule.default.handleSetJSResponder')

I follow the steps of react-native docs.
npx react-native init SelfApp --template react-native-template-typescript
and then follow the steps of react-native-navigation.
yarn add #react-navigation/native
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context #react-native-community/masked-view
then i add code
import 'react-native-gesture-handler';
to the first line of app.tsx.
then run yarn start, I got this error.
i tried a lot of times, but still in trouble, and here is my package.json
Hey according to this discussion on react-native-gesture-handler's GitHub, it's either a problem of linking, if you are on Android or a problem of some pods not being installed if you are on iOS.
It would be helpful to know which version of React Native you are using because if it's >= 60, it should support auto-linking, and if it is < 60, you should link the library manually.
In that last case:
Try these steps
For iOS:
$ cd ios
$ pod install
Another possible solution that has worked for other people, according to the discussion I mentioned above (see this specific response):
1 - Delete/Remove your node_modules directory
rm -rf node_modules
2 - Install your dependencies again
If you are using Yarn $ yarn install or if you are using npm npm install
3 Clean your Gradle
cd android
./gradlew clean
cd ..
react-native run-android

I am trying to run react project through yarn but it is giving me error what should i do now?

i am trying to run react porject through YARN but it is giving error react-scripts.js already exists in file what should i do now
enter image description here
please run command- "npm install" ,it will install react-script dependency.

How can i solve "No project found" error when installing react

I am new to react and i am taking my first course on openclassrooms on react.
The instructor is using the command
yarn global add create-react-app
to setup but when i run the commdand i get the error below
Usage Error: No project found in /E:/Web Dev/React/react-project
i have tried to use the command below that is provided in the react documentation but i stil get the same error
yarn create react-app my-app
How can i solve the problem i have looked up on the react documentation but still cannot find the solution.
I experienced the same issue and solved it as follows:
Uninstall yarn from npm using npm uninstall -g yarn
Install Yarn from Installation - Yarn Classic
Restart PowerShell / CMD
Before performing the above steps yarn --version printed 2.0.0-rc.27 on my machine. Now it prints 1.22.4.
Having Yarn 2.x globally installed is discouraged accourding to Installation - Yarn 2.x.

Failed to run jetifier React Native

I tried to run react-native run-android and I got this error.
info Running jetifier to migrate libraries to AndroidX. You can disable
it using "--no-jetifier" flag.
error Failed to run jetifier. Run CLI with --verbose flag for more details.
Error: spawnSync C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\jetifier\bin\jetify ENOENT
at Object.spawnSync (internal/child_process.js:1002:20)
at spawnSync (child_process.js:614:24)
at execFileSync (child_process.js:642:13)
at Object.runAndroid [as func] (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:101:41)
at Command.handleAction (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli\build\cliEntry.js:160:21)
at Command.listener (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:315:8)
at Command.emit (events.js:198:13)
at Command.parseArgs (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:651:12)
at Command.parse (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:474:21)
at setupAndRun (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\#react-native-community\cli\build\cliEntry.js:210:24)
Use this :
step 1: add these two lines in gradlew.properties Visit for complete guideline
android.useAndroidX=true
android.enableJetifier=true
step 2: use these commands
First of all remove node_modules folder and reinstall it using
npm install
or
yarn
and then
npm install --save-dev jetifier
npx jetify
npx react-native run-android
Call
npx jetify
every time when (your dependencies update or every time you install node_modules you have to jetify again)
When I was getting this error I noticed that I'm not in the main project folder I was inside the cd android folder. So I just cd .. it and it worked.
Use this:
react-native run-android --no-jetifier
If you run npx react-native run-android in android folder. That error will happen. You need to run-android in the root directory.
I'm using yarn so I had to use
yarn react-native run-android --variant=release
(Not npx)
Also to run in the simulator (not on a device) I had to install some extra stuff in Android Studio, see https://stackoverflow.com/a/64942777/3469524
react-native run-android --no-jetifier
and again start server
react-native start
Mostly it happened by cache, metro server closed or already generated package in android folder. check jetifier is enabled in gradle.proporties
android.useAndroidX = true
android.enableJetifier = true
First close your metro server terminal window and run $ yarn android // this is almost solve your issue otherwise follow the below steps
Then run
$ cd android && ./gradlew clean
Clean the cache and build folders - generated & intermediates
$ ./gradlew cleanBuildCache
Create the debug apk
$ ./gradlew AssembleDebug //output: Build successful
then check your apk output folder.
Run the react native package
$ yarn android || npx react-native run-android
Now it's working fine.
The issue is in React Native CLI v2.6.1
Use Below steps to resolve the issue:
If you use lock files (yarn.lock or package-lock.json) - find the #react-native-community/cli entry, remove it, run yarn install / npm install once again.
If you don't use lock files – remove node_modules and run yarn install / npm install again.
Run yarn list #react-native-community/cli or npm list #react-native-community/cli and verify you're on the latest version (v2.6.2).
Run react-native run-android
Just run the following command in the project's directory:
npm install --save-dev jetifier
Check current directory set to project root and then run npx react-native run-android
Just change from "C" directory to any other directory and then install/run starting from here
"npm install -g react-native-cli" .
Then create new project "react-native init AwesomeProject "
use Yarn to install dependencies fast.
It worked for me.
I use this react-native run-android --no-jetifier worked me

Cannot resolve 'react-native'

I am trying to import react-native module into my react app. When I start my app server using 'npm start', I get the following error :
Module not found: Can't resolve 'react-native'
I have done following steps:
cleaned npm cache using 'npm cache verify'
deleted node_modules
rerun the command 'npm install'
checked package.json file if it has react-native dependency listed
Nothing worked for me. Please help!!
Try to recreate your app using the react native CLI. Use the command npm install -g react-native-cli, then use react-native init ProjectName and after that try to run the project.
If you cannot create a new app for any reason, try to install the react-native-cli anyway and try to run react-native run-android or react-native run-ios (depending on the plataform you want to use as a tester_ instead of npm start.

Resources