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

Time:12-07

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

CodePudding user response:

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.

CodePudding user response:

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