npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)

devZack picture devZack · Apr 23, 2020 · Viewed 23.1k times · Source

When I want to create a react app I'm encountering the following error:

npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\info\AppData\Roaming\npm-cache\_logs\2020-04-23T02_54_45_865Z-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 app2/ from C:\Users\info
Done.

Answer

Carl von Buelow picture Carl von Buelow · Apr 23, 2020

Sounds like you have a slow connection. 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.