Failed to run jetifier React Native - reactjs

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

Related

Unable to find expo project - have you run yarn / npm install yet?

I'm Unable to execute the expo start command.
$ expo start
[09:43:39] Starting project at C:\Users\Subrata\Desktop\example-app
[09:43:40] Unable to find expo in this project - have you run yarn / npm install yet?
either you havent installed dependencies yet, which you can do by running npm install, or you might be outside the project folder, in which case just run cd projectName

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

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.

How to fix: Npx create-react-app does not install everything only package.json and node modules

I'm trying to create a new react app, but whenever I do npx create-react-app or npm init react-app, only the node_modules and a portion of package.json is installed.
npx create-react-app new-app
(https://imgur.com/iJDVQ3E) -> Current package.json and folder structure
Expected public folder and script run commands in package.json
I know it's been two months, but I came across this exact issue and found the next solution:
You only need to update your npm and node modules, they are outdated for us or missing something important and that is why we get no template folders. Try below command:
run npm install -g update-node
run npm update npm -g
These two commands should fix it, if not, let me know, maybe I forgot one command to tell you.
Uninstall react in case its installed globally by running the command "npm uninstall -g create-react-app". then run "npx install -g create-react-app".
npx comes with npm 52+ updated versions
tried using the above 2 commands and got created all the required folders under react app.
run npm install -g update-node
run npm update npm -g

Create React App not working

Help! I have no idea what is going on here, create react app is not working I have also tried reinstalling and yet to no avail, please help!
Npm version: 5.4.2
Node version: 8.70
Tried the npm install --save --save-exact --loglevel error react react-dom react-scripts
In my case, "create-react-app" was not installed. to install run this command
npm install -g create-react-app
Once installation successful, try running
npx create-react-app hello-world
If this works for you. Great else comment what worked for you,
Please try this:
npm cache clean --force
I also got the same issue and tried to resolve for a long and finally resolved using this command,
npx create-react-app#latest my-app --use-npm
I had the same problem and had to do the following:
npm uninstall -g create-react-app
npm uninstall create-react-app
After this I was able to create the app with:
npx create-react-app project-app
I had the same problem, and I solved it by:
1. update the npm version (npm install npm#latest -g)
2. clear the cache (npm cache clean --force)
3. create the react project (npx create-react-app todo)
(create-react-app was already installed)
I had similar issue while tried creating new react app with create-react-app, but related to some random JSON reading issues while installations like.. >= 5.0 || 4.0 ..
But the fix below solves multiple and similar issues.
First of all, make sure you have required or latest version of node installed.
npm install npm#latest -g
Before using create-react-app make sure you clean npm cache using npm cache clean --force
Now, is should be fine to create new react app with npx create-react-app tl-app or npx create-react-app . if you want to create current directory as project root.
Make sure you are not running any antivirus, stop/pause all antivirus or protection software.
You can also try
use create-react-app projectname --save
or create-react-app projectname --save-exact and start again
OR
as the error suggests, you should use a newer version of node. You are using 8.9.4, you should probably use 8.12.0 LTS.
It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production.
You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. To create a project, run:
npx create-react-app my-app
cd my-app
npm start
Note:
npx on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.
Create react app provides more information regarding this.
It may be the problem of cache also, so can also try:
npm cache clean --force
Edit 1: This may be due to slow internet speed, Please check the
internet and try again.
npx create-react-app .
( the .) means create project on this folder so you should manually create if you do that
For the windows machine following command worked for me
yarn create react-app my-app
cd my-app
yarn set version berry
yarn
yarn start
The problem on my machine was caused by yarn. I am windows 10 and after uninstalling yarn using npm uninstall -g yarn, my script run correctly. So
Open terminal and type: npm uninstall -g yarn
Once done, close terminal and open new one
type create-react-app (app name) and this should create your app :)
Please note that the above steps assume that you already have node and react-cli installed on your machine.
on Ubuntu 18.04
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
What I did, is going to
C:\Users\mycomputerName\AppData\Roaming\npm\
I changed the name of this file
create-react-app.ps1
to
create-react-appOld.ps1
or you can delete it, then it worked fine
Tried all the above methods but no luck:(
Step1 : Reinstalled Node js
Step2 : Check whether environment variables has been created. if not create one for nodejs,npm and composer
Step3: Also add "C:\Windows\System32" to the global PATH environment variable.
Step4: Then use "npx create-react-app my-app" to create react project
Step5: Run the commmand : cd my-app and npm start
Step6: It will work
I finally got it to work. An anti-virus in my system was causing it not to work property. I unistalled it and it's working as expected.
After no luck with updating my npm version and doing npm cache clean --force I ended up just doing a fresh install of node which fixed the issue for me.
HAD the same problem. Running Node with cra. installed cra -g for starters.
npm install -g create-react-app
then downgraded react-scripts to version 2.1.8
npm install react-scripts#2.1.8
created a .env file in root directory and added this to it.
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
SKIP_PREFLIGHT_CHECK=true
Then you do the typical delete node_modules folder and the package-lock.json file.(NOT PACKAGE.JSON!!!)
then:
npm install
npm start
This worked for me. Sorry I'm not more informative on why this worked for me. I'm still trying to understand why it didn't work in the first place.
I just did it now after messing around with it all yesterday.
Installed react globally like people have said.
then I used 'git bash here' to open terminal in the directory i want
oddly, it worked when I removed npm. I know it's weird, I've never had to do that and it makes no sense but its working so:
create-react-app my-app-name
I'm on windows 10 by the way.
If there is anyone having this issue that you can not find your project when you
yarn create-react-app (name of project)
npx create-react-app (name of project)
then just be sure that you are in the right directory.
use this command in your terminal
cd ..
now search the project name by
cd (project name)
you should find your directory here.
Please do this, I hope it will fix all of your problems
1- npm i -g create-react-app
2- create-react-app my-app
Find the folder and where a folder named npm is present and add it into environment variables (path)
I also experienced the same problem and SOLVED IT.
This is what I did.
Restart your machine(computer)
Deactivate your anti-virus. I chose the "permanently" option
Open the terminal and run the "create-react-app" command again, It will definitely do the trick.
Activate your anti-virus
And get working :-)

Resources