ERR_SOCKET_TIMEOUT when using npx to create react app

PS C:\Users\User> npx create-react-app client

Creating a new React app in C:\Users\User\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 Invalid response body while trying to fetch https://registry.npmjs.org/eslint: 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\User\AppData\Local\npm-cache\_logs\2022-04-18T02_58_18_148Z-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:\Users\User
Done.
npm ERR! code 1
npm ERR! path C:\Users\User
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-react-app "client"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Local\npm-cache\_logs\2022-04-18T02_58_06_939Z-debug-0.log
PS C:\Users\User>

Upvotes: 1

Views: 2948

Answers (2)

A.J. Olukanni
A.J. Olukanni

Reputation: 23

I had the same problem with npx create-react-app app-name and create-react-app app-name with the create-react-app installed globally.

npm has little tolerance for slow internet connection unlike yarn. I even tried to reset the timeout property in the config using the command from the terminal:

npm config set timeout 240000

Also, tried

npm config set fetch-retry-mintimeout 120000

and

npm config set fetch-retry-maxtimeout 240000

None of these worked for me.

Finally, I got rid of the issue by simply using

yarn create react-app app-name

yarn hardly fails on slow connection as it would always try to reconnect and continue its progress from where it stopped.

Install the latest version of yarn globally with npm using:

npm i -g yarn@latest

Check if yarn was installed with

yarn -v

Then run yarn create react-app your-app-name while in your desired project directory.

Upvotes: 2

This help me

npm -g list

npm install -g create-react-app

Upvotes: -1

Related Questions