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

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.

Related

yarn install wont run on my project keeps telling me that it couldn't find the binary react-script start

my package.json
the error i get
all my scripts dont work it keeps throwing the same error everytime.
i have cloned the repo in a different location and reinstalled the dependencies but still yarn start wont run.
what could be the problem?
try running your project with this yarn run start or just add react-scripts with yarn using this command yarn add react-scripts because maybe react-scripts is not installed for some reason

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.

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

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

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

react-scripts missing after install redux

i created react app according steps described here https://www.sitepoint.com/getting-started-react-beginners-guide/
npm i -g create-react-app
create-react-app myapp
yarn start
Everything worked ok, so i tried install redux as it described here
https://redux.js.org/docs/basics/UsageWithReact.html
npm install --save react-redux
I got this message
react-redux#5.0.7
added 3 packages, removed 1061 packages and updated 18 packages in 14.541s
and now when i try
yarn start
i get message
yarn run v1.3.2
$ react-scripts start
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Whats wrong? I don't understand why is react-scripts not working. I thought that --save adds the third-party package to the package's dependencies and have nothing to do with other packages.
Iam thankfull for every advice what i did wrong and how to fix it.
Thanks
Instead of npm install --save react-redux you should install redux package using yarn.
yarn add redux
issue :
You are creating app using yarn package manager and then adding new packages using npm causing to eject the packages installed using yarn.
Because of this react-scripts getting remove throwing the error.

Resources