Error when I run npx create-react-app my-app - reactjs

I have tried these two commands and am getting the same error.
npm clean cache --force
npx create-react-app client -timeout=120000
$ npx create-react-app client -timeout=120000
npm WARN exec The following package was not found and will be installed: create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Creating a new React app in C:\web_dev\MERN\projects\booking-app\client.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network request to https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz failed, reason: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\web_dev\MERN\projects\booking-app\tmpnodejsnpm-cache\_logs\2021-12-29T13_37_03_989Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting client/ from C:\web_dev\MERN\projects\booking-app
Done.

I have just faced the same issue when upgrading an old project. What solved, in my case was:
If you use yarn:
yarn global remove create-react-app
yarn cache clean
If you use npm:
npm remove create-react-app
npx clear-npx-cache
Also make sure there is no folder in the directory where you will created the new React project because you can get another warning similar to:
The directory . contains files that could conflict:
<the file(s) name here>/
Either try using a new directory name, or remove the files listed above.
After that, npx create-react-app . ran smoothly.
Those steps described above solved the following subsequent warnings (versions may vary).:
Global warning
You are running "create-react-app" 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
tar warning
tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

Even I was getting the same error and then saw your question I closed all the task and run this command "npx create-react-app my-app" again it got solved!

I had the same problem so I uninstalled it globally then reinstall:-
npm uninstall -g create-react-app
npm uninstall create-react-app
Then I used npx:-
npx create-react-app project-app
Tell me if this works for you

Try this:
npm install -g npm#latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app

I had the same error sometime ago,
just make sure you don't have any space between the name of your directories folders
like Desktop/react project/my-react-app ...this is wrong
try this
Desktop/reactproject/my-react-app ... correction

Related

can't able to install react using npx create-react-app

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/eslint-plugin-jsx-a11y: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/purushot/.npm/_logs/2021-12-07T08_23_28_234Z-debug-0.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
npm version is 8.0.2
node version is 16.13.1
ubuntu version is 20.04.3
can look at full log here https://codepen.io/purushot-frontend/pen/OJxNPgQ
update: Can't able to find exact reason but rolled back to node version 12.22.7, npm v6.14.15 and its working again.
This seems to be a slow internet connection issue. Try increasing the timeout from 30s to 60s by adding this to your .npmrc file:
"timeout=60000"
You could also try adding "prefer-offline=true" if you are trying to save bandwidth or have a slow connection
Note: if you don't have an .npmrc file setup yet, you can create one here
for Windows: C:\Users{username}.npmrc
for Mac/Linux ~/.npmrc
Or you can create one in the same directory as your project's package.json file.
I was facing the same issue when creating a react-app using npx create-react-app . And I fixed my problem by running the following command.
npm cache clean --force
And then
npx create-react-app [app-name]

create-react-app : npm ERR! Unexpected end of JSON input while parsing near '....'

Describe the bug
npx create-react-app my-app doesn't work for me
i tried npm cache clean --force but i get the same error again and again
Steps to reproduce
npm cache clean --force
npm / npx create-react-app front
npm init react-app front
npx: installed 98 in 37.068s
Creating a new React app in /home/h4kst3r/Desktop/APIs/restaurant-API/front.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! Unexpected end of JSON input while parsing near '...zAJNgZjZUkJ08ybAxwNnR'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/h4kst3r/.npm/_logs/2020-05-20T20_47_49_189Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting front/ from /home/h4kst3r/Desktop/APIs/restaurant-API
Done.
System:
OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
Its happened because of slow internet . So wait till ur internet connection is normal. Or install all dependencies one by one
.
If npx create-react-app my-app command not working and throws an error like: npm ERR! Unexpected end of JSON input while parsing near '...zAJNgZjZUkJ08ybAxwNnR', Just check your npm version:
npm --version
npm -v
and if required update it:
npm install -g npm#latest
It will definitely work.
First check for npm version by running the following command npm --version. if you have an npm version then try instally npx globally with the help of npm i -g npx. if npm and ngx are installed properlly then this will work .
sudo npm i -g npx --force worked for me.
You should do it as a root user. Open your terminal and type sudo -i or sudo -s. After successful login, the $ prompt would change to # to indicate that you logged in as a root user on Ubuntu. Then if you use `create-react-app it should actually work :)
There are probably two things that can be at fault.
Poor internet connection.
outdated npm version.
update your npm and seek a strong internet connection.

Create-react-app don't run even just after create it

*npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! github#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the github#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:*
or sometimes I am different kind of errors just after creating the app. which means no modifications to the default automatic generated project.
and I managed to solved it.
the issue seems to be with my Yarn. incomplete uninstall or something like that. can't solve it by just reinstalling Yarn or uninstall it again. because of that, NPM create-react-app also create bugs, which IDK how.
but the solution is amazing, I just created the project in a different folder. trust me I'm not lying , different location do works in NPM. so I believe I need to format my computer to solve this 100%.
The cause maybe due to I have installed create-react-app via NPM globally and tries to install Yarn create-react-app. anyway, by using a different folder location, my issue was fixed completely.
Formatting the computer isn't a solution for this.
This error indicates that you probably have installed through npm install -g create-react-app
which is old version.
I think you need to uninstall and install again using npx create-react-app
Steps
1 - npm uninstall -g create-react-app
or
yarn uninstall -g create-react-app
2 - npx create-react-app my-app
npx comes with npm 5.2+ and higher, see instructions for older npm
versions.
check this create-react-app latest one

create-react-app throws error: "Missing dependencies in package.json"

So I'm trying to run reactjs official tutorial and with the first line of code:
npx create-react-app react-tutorial
...I get the following error:
npx: installed 91 in 12.692s
Creating a new React app in /home/foo/projects/react-tutorial.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.12.3
[1/4] Resolving packages...
warning react-scripts > fsevents#2.0.6: Please update: there are crash fixes
[2/4] Fetching packages...
[-----] 1/1297Missing dependencies in package.json
I read some where else to clean or force clean npm cache but that didn't work either:
npm cache clean --force
I'm on ubuntu running latest node (10.16.0) I also tried with 8.*
It seems that the error is discussed in this issue:
This seems to be a Yarn issue.
The workaround is to use npm instead of yarn:
create-react-app myproject --use-npm
If installing with npm you experience the following error:
npm ERR! cb() never called!
increase the ulimit in your .bashrc, .bash_profile, and/or .profile by updating (or removing) the below command:
ulimit -n 20000
Looks like you are using yarn instead of npm. Try --use-npm flag like this :
npx create-react-app react-tutorial --use-npm
I fixed this issue by installing yarn and then:
npx create-react-app my-app
cd my-app
npm start
Some people uninstalled yarn and used npm instead, I am not sure why npm did not work for me.
Try to upgrade npm version on your system.
Also upgrade your node.js version to the latest one.
I have solved this issue here all steps are written look into it..
reinstall npm(react) using the following command
npm install -g npm-reinstall
to some users, it may ask to audit fix do it
npm audit fix
npm audit fix --force
after it will take 2-5 min then write our command for creating a new project in react using npm
npx create-react-app amazon --use-npm
After the common step to start the server
cd amazon
npm start

Why create-react-app doesn't create new app

I installed the latest version on Node JS with npm and cannot run create-react-app.
The following problem occurs:
Creating a new React app in C:\wamp64\www\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '....tgz"}},"2.3.4":{"nam'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2019-02-26T21_21_48_727Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\wamp64\www
Done.
Versions:
Node v10.15.1
npm 6.7.0
Can somebody help?
After running npm cache clean --force
the another error occurs:
$ create-react-app bob
Creating a new React app in C:\Users\Ivana\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...,"#babel/plugin-synta'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache\_logs\2019-02-27T09_18_28_856Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\Users\Ivana
Done.
From https://create-react-app.dev/docs/getting-started#creating-an-app
npx create-react-app my-app
(npx comes with npm 5.2+ and higher)
But you used
`create-react-app my-app`
If you use npm 5.1 or earlier, you can't use npx. Instead, install create-react-app globally:
npm install -g create-react-app
Now you can run:
create-react-app my-app
I was also not able to create a new app but when I follow these step
then it works for me.
After a few searches, I found this :
If you've previously installed create-react-app globally via npm install -g
create-react-app, we recommend you uninstall the package using npm uninstall -g
create-react-app to ensure that npx always uses the latest version.
So if you installed create-react-app with
npm -g install create-react-app
just run :
npm -g uninstall create-react-app
npx create-react-app
It should do the job
I was able to solve this problem by,
running
npm cache clean --force
then
npm create-react-app my-app

Resources