tnsaturday
tnsaturday

Reputation: 593

How to solve npm ERR_SOCKET_TIMEOUT error when creating react app?

I use npx create-react-app to boot strap my project. Installation process crashes with:

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/@babel%2fhelper-compilation-targets: 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'

I open that url with the Chrome browser and it works just fine:

enter image description here

How do I solve this problem?

Upvotes: 1

Views: 13593

Answers (2)

Efrat Ifergan
Efrat Ifergan

Reputation: 370

I had the same error. The solution was to change the definition of the timeout.

It worked for me like a charm ✨

For changing the timeout, Run these two commands:

npm config set fetch-retry-mintimeout 20000

npm config set fetch-retry-maxtimeout 120000

I hope this helps.

Upvotes: 5

Aqib Hussain CH
Aqib Hussain CH

Reputation: 44

tnsaturday. Recently I also faced a similar problem as you. I solved this problem by simply uninstalling the latest node.js version which is 17.5.0 and installing 16.14.0 LTS. So, if you installed the latest version of the node then shift back to the previous version. I hope in this way you can solve your problem.

Upvotes: 1

Related Questions