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

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]

Related

Not able to setup react project using create-react-app

Below is the error I am getting after running the command
C:\Users\parde>npx create-react-app app
Creating a new React app in C:\Users\parde\app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! errno ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/#babel%2fcore: 10552:error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:677:
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\parde\AppData\Local\npm-cache\_logs\2022-09-09T13_12_40_326Z-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 app/ from C:\Users\parde
Done.C:\Users\parde>npx create-react-app app
I tried:
Run npm cache clean --force
Then Run npx create-react-app (project name)
This seems to be a network-related error. Have a look at this thread.
Try any of the following:
use a VPN
allow NodeJs in the firewall
update your npm npm install --location=global
reinstall NodeJs
Theirs an issue related to it in the NPM repo
Seen to be something about the windows defender firewall
https://github.com/nodejs/help/issues/3815

npm ERR! A complete log of this run can be found in: npm ERR! Aborting installation. npm install --no-audit --save --save-e

PS E:\React> npx create-react-app task
Creating a new React app in E:\React\task.
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! network 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:\Users\santo\AppData\Local\npm-cache_logs\2022-02-15T06_08_33_703Z-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... node_modules
Deleting generated file... package.json
Deleting task/ from E:\React
i'm gettibg this msg can anyone help me
Try again with better connectivity. Because npx fetch data from server which required network connection Once you successfully generate project you can work without network connection.

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

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

how to resolve socket timeout while creating react app

PS C:\Users\HP\Desktop> npx create-react-app enda_react
Creating a new React app in C:\Users\HP\Desktop\enda_react.
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! request to https://registry.npmjs.org/bfj failed, reason: Socket timeout
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Local\npm-cache_logs\2021-03-10T03_17_13_731Z-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 enda_react/ from C:\Users\HP\Desktop
Done.
i tried different methods such as
- increase timeout,
-upadate npm versions,
-unistalled previeous create app and installed new one,
-cleared cache,
all these methods doesnt worked for me,someone please help
I've faced the same issue in node V16.14.0, then I've added a timeout flag to solve this issue.
npx create-react-app clients -timeout=100000
I had the same problem, then I decided to install react js with this command:
npm init react-app app-name

Getting trouble to create a new react app

While I'm Tring to create a new react app I'm getting an error message below,
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
npm ERR! code ECONNRESET npm ERR! errno ECONNRESET npm ERR! network
Invalid response body while trying to fetch
https://registry.npmjs.org/jest-resolve: aborted 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:\Users\Akhlak Hossain
Jim\AppData\Local\npm-cache_logs\2020-11-17T06_20_31_124Z-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 new-react/ from
J:\learning_time_practices Done. npm ERR! code 1 npm ERR! path
J:\learning_time_practices npm ERR! command failed npm ERR! command
C:\Windows\system32\cmd.exe /d /s /c ""create-react-app" "new-react"
"--use-npm""
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\Akhlak Hossain
Jim\AppData\Local\npm-cache_logs\2020-11-17T06_20_31_497Z-debug.log
Can you try first this one npm config set registry http://registry.npmjs.org/? then try again to execute npx create-react-app [your_app_name]
There May be a problem with automatic proxy setup, try this out
go to settings> Network and Internet > Proxy
and then under Automatic proxy setup turn off Automatically detect settings on Windows. And then open a command prompt and type the following command.
npm uninstall -g create-react-app
It worked for me.
In my case, Antivirus was the culprit which was blocking some files at the time of npx operation. This helped my case

Resources