Run 'create-react-app' failed - reactjs

I came across the following problem
I ref react-app tutorials to create a react-app demo. When I run create-react-app my-app command, it failed.
After that, I have changed npm mirror to taobao.org(in China). But it also failed.
npm config set registry https://registry.npm.taobao.org
So, how to slove the problem.

I uninstall yarn and reinstall .
Reinstall node
Reinstall react-app.
Need administrator's permission to install react-app in CMD.
With the method, I install react-app successfully!

Related

create-react-app not working. Getting error "Module not found"

This is what I'm getting
I am not able to create a project using create-react-app, I get the error "Module not found".
Node version is 17.0.1 and Npm version is 8.1.1
I have reinstalled nodejs 3 times now and have tried different commands like
npm install create-react-app -g
npm cache clean --force
P.S - I have updated the nodejs to 17.0.1 as the picture version shows 16.13.0
You can try with npx create-react-app my-app.
Visit for more details create-react-app
To create a new app, you may choose one of the following methods:
npx
npx create-react-app my-app
npm
npm init react-app my-app
npm init <initializer> is available in npm 6+
Yarn
yarn create react-app my-app
yarn create is available in Yarn 0.25+
So after almost 3-4 hours of trying different things, it has worked.
I dont know which particular thing would have helped it to work but following are the things I tried -
Delete npm and npm cache folder.
Reinstall the nodejs (LTS version).
Create the app in another folder.
Used power shell instead of CMD.
npm fix
npm fix --force

Creating a react App starts aborting installation

While creating a new react app, getting this error.
Aborting installation. yarnpkg add --exact react react-dom react-scripts --cwd C:\Users\.... \my-app has failed.
I know #5328 gave solution by removing . npmrc file here - https://github.com/facebook/create-react-app/issues/5328#issuecomment-429148117
I am new to react .. so can some one please let me know how do I find .npmrc file and how do i remove it? Or how do I create a new react app without having this error?
I know we can create a react app with the following command:
npx create-react-app my-app
or
yarn create react-app my-app
or
npm init react-app my-app
Thanks!
Okay,
I solved this problem by following the below steps:
npm install -g npm#latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app
I faced the same issue while creating a new app with CRA.
I tried all the below-mentioned solution:
1) Uninstall Yarn and install again.
2) yarn cache clean
3) npm uninstall -g create-react-app and install again.
Here's main issue:
error #typescript-eslint/eslint-plugin#2.13.0: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.11.0"
error Found incompatible module.
You may have got something similar. Look a couple of lines above "Aborting installation"
In my case, I was using Node version "10.11.0". I install a stable version of Node and it worked absolutely fine.
To double-check I tried to simulate the issue by changing the version with the help of NVM, and got the same issue.
Please refer to the error message and you'll figure out the culprit.
Note: I would still suggest keeping the updated and stable version of Yarn and CRA.

On npm start npm ERR! A complete log of this run can be found in:

On npm start I am getting
npm ERR! A complete log of this run can be found
in:C:\Users\asus\AppData\Roaming\npm-cache_logs\2019-07-05T11_54_44001Z-debug.log
How can I solve this, please help me out
Type this command and your problem will be solved.
npm set registry http://registry.npmjs.org/
You should be in the right folder before you start react. Your main folder which includes public,src, package.json files should be targeted with changing directory and then npm start can be used
I was facing the same problem. And this is how I solved it.
Little scenario here.
I downloaded the other's project from GitHub ; did not started from the scratch. I extracted the zip. It created the folder react-stop-watcher with another folder react-stop-watcher.
Initially I hit the npm start command in
C:\Users\Lenovo\Downloads\react-stopwatch-master\
It throw the same npm ERR!. We need to get into
C:\Users\Lenovo\Downloads\react-stopwatch-master\react-stopwatch-master\
instead And then hit
npm install
npm start
And now my project is up and running.
I faced the same problem.
So, first I uninstalled the previous version by using
npm uninstall -g create-react-app
to ensure npx always uses the latest version.
And then reinstalled with the same code procedure:
npx create-react-app my-app
cd my-app
npm start
And it worked!
Most probably I think you are using mysql but you not install mysql or not import the mysql.
I am also getting the same error but i resolve it by installing and importing the mysql.
try this
npm install mysql
import mysql in the file
var mysql = require('mysql');
change the parent name u have give space between them like
"hello world"
"hello_world" folder name should be this.
Basically, the error is just because of a network issue, might be your internet connection off or low internet connection try after some time that definitely works.
# to create project
npx create-react-app projectName
# to run server
npm start
Just follow this code
npm install
Then
npm audit fix
Add SKIP_PREFLIGHT_CHECK=true to a .env file and that's it. Will solve it if you are using react
cd to your project directory(myapp) where you have node_modules, public, src etc and try npm run.
An error is coming coz you are not in the correct directory. Simply use cd(react project name) i.e.in may case its cd my-app(that I created using npm create-react-app my-app) and then simply run npm start
enter image description here
First You need to Delete all logs files in you Node cash folder
*C:\Users\asus\AppData\Roaming\npm-cache_logs*
After that delete the package-lock.json file
run npm install and run your project
just type the following in terminal:-
pwd,cd NameOfFolder

Reactjs, yarn etc

I want to create a test React apllication but I am stuck at the installation:
I install Yarn with npm because the yarn msi doesn't start, so:
1. npm i .g yarnpkg
2. yarn create react-app test
and I read this error message:
yarn create v0.15.1 error Couldn't find a package.json (or bower.json)
file in C:\Users***\React
at C:\Users***\AppData\Roaming\npm\node_modules\yarnpkg\lib\config.js:355:13
at Generator.next ()
at step (C:\Users***\AppData\Roaming\npm\node_modules\yarnpkg\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
at C:\Users***\AppData\Roaming\npm\node_modules\yarnpkg\node_modules\babel-runtime\helpers\asyncToGenerator.js:28:13
info Visit http://yarnpkg.com/en/docs/cli/create for documentation
about this command.
I tried to search it on Internet but they did not solve my problem. Please, help me.
To anyone visiting this thread in 2021, it's very likely you're running
yarn create-react-app my-app instead of yarn create react-app my-app.
You should initiate a npm project first.
cd projectfolder
npm init
yarn create react-app my-app

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