'npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)
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.
Solution 1:[1]
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.
Solution 2:[2]
I had a slow connection and I updated the timeout value to .npmrc
using:
npm set timeout=100000
And to check if the value is updated (Mac): vi ~/.npmrc
Solution 3:[3]
Users are extremely likely to face this issue if they are on a slow internet connection. To counter this, you need to increase the timeout in the npm's config file. And here's how to do it:
- Find the
.npmrc
file (located in the nodejs installation folder; in my case, it's inF:\Installations\nodejs\node_modules\npm
folder. But for you, it might be inC:\program files
folder). - Open the
.npmrc
file and append this line:timeout=240000
(usually it is 60 seconds I suppose, but since my connection was way slower therefore, I had to increase it to 240 seconds or 4 minutes, you can keep it 120000 for 120seconds) - Save the file
Since create-react-app fails midway, it can easily break npm's package.json file thus leading to this sort of issue:
Unexpected end of JSON input while parsing near
Therefore, before running the npx create-react-app
, run the following command: npm cache clean --force
as it cleans the cache and (i think) repairs the package.json
file.
Solution 4:[4]
This error occurs due to slow internet connection. Try installing when you get a better speed. If better speed doesn't solve your problem try this.
npm cache verify
npm cache clean --force
Solution 5:[5]
I was facing the same issue. I Solved it like this: create a new file with no name just an extinction of .npmrc open this file in any editor and type timeout = 90000 save the file and in you terminal type
npm cache clean --force
npm install create-react-app
npx create-react-app ./
Note: this error occurs because of slow internet speed
Solution 6:[6]
I enabled IIS and the issue was solved for me:
- do to Control Panel -> Programs -> Programs and Features
- click on Turn Windows features on and off
- make sure the Internet Information Services is checked
- click OK and wait for some minutes
Solution 7:[7]
I was facing the same issue when create a react-app using npx create-react app . And i fixed my problem by running the following command.
npm cache clean --force
I hope you find this helpful
Solution 8:[8]
I fixed the problem by setting timeout in user local .npmrc
file to
timeout=600000
90000 is not enough for downloading many packages for projects with lot dependencies in package.json
Solution 9:[9]
I fixed the problem by running:
npm config set registry "http://registry.npmjs.org" --global
It appears the problem is related to the following post:
npm install gets stuck at fetchMetadata
And @CptUnlucky's solution worked for me on macOS Catalina 10.15.7, node v16.0.0, npm v7.12.2, nvm v0.38.0
Solution 10:[10]
I was facing the same issue and I solved it by enabling the Internet Information service (IIS) feature of the window. Enabling the IIS Steps:
Windown + r
Type appwiz.cpl and click OK
click on Turn window features on or off (on the Left top side)
wait some seconds and check the Internet information service option
Now wait until window apply changes.
create project again.
Solution 11:[11]
I have faced the same issue. I tried all solutions over StackOverflow or Github discussions but nothing worked.
I changed the .npmrc
file under the Users folder in C in Windows and changed the timeout from 30000 to 90000. See if 60000 works!
Solution 12:[12]
In my case it was the issue related to npm verison 6.14*
Downgrading to npm verison 6.13.7 solved for me
npm i -g [email protected]
It's also an newly opened issue you can check more details about it at https://github.com/npm/cli/issues/1185
Solution 13:[13]
You just need to run npm i [email protected]
or npm I -g [email protected]
if you wanna this to be global version.
After that, just to make sure, run " npm -version " to see what version you are using.
Solution 14:[14]
Downgrading to npm version 6.13.7 worked for me.
Solution 15:[15]
Try this:
npm cache clean --force
npm config rm proxy
npm config rm https-proxy
And remove your node_modules
within your user.
In Windows, it is
C:\Users\${select_your_user}\AppData\Roaming\npm\node_modules
Solution 16:[16]
I was facing the same issue when running npm install
on Docker.
I had to pass the HTTP and HTTPS proxy values to the image while building it.
docker build --build-arg HTTP_PROXY=http://<your_company_proxy> --build-arg HTTPS_PROXY=http://<your_company_proxy>
It worked fine after I passed these parameters.
Solution 17:[17]
In my case it was the issue related to npm verison 6.14* Downgrading to npm verison 6.13.7 solved for me
npm i -g [email protected] It's also an newly opened issue you can check more details about it at https://github.com/npm/cli/issues/1185 it is works for me
Solution 18:[18]
Editing the .npmrc file to 80000 works. If not, globally uninstall create-react-app:
"npm uninstall -g create-react-app" then run "npx create-react-app ./"
Solution 19:[19]
In case you are still running into this issue below with the error:
Invalid response body while trying to fetch https://registry.npmjs.org/eslint-config-react-app: Socket timeout
Run this script: npm install react --registry=https://registry.npmjs.org
and then npx create-react-app mypp
for your react app installation. Happy coding
Solution 20:[20]
I recently have the same issue and following steps would help you.
- npm config set registry "http://registry.npmjs.org" --global (sets registry) (Try Again)
- Go to you user folder find .npmrc file there and remove content of it.
- run npm cache clean --force
- still errors - Remove the content of npm base folder usually inside User/AppData/roaming/npm/...
Solution 21:[21]
I tried everything including factory resetting my Mac. Then after reinstalling everything and still having the same issue, I typed into the terminal and ran:
npm set timeout=100000
then sat my computer next to my router and ran npx create-react-app again and it worked!
Solution 22:[22]
Sometimes it won't work if you use only letters in your app name e.g first I have used "myapp" and that was not working though I have done all the other stuffs correctly like set timeout = 240000 in .npmrc file and run the following commands
npm cache clean --force
npm install create-react-app
npx create-react-app myapp
but that not working for me then I have just changed my project name from myapp -> my-app and it worked perfectly. So, If you are facing the same issue try them out. Hopefully, it saves your time.
Solution 23:[23]
I tried many things for 3 days, then i figure out that new versions of nodejs doesn't work so fine for some computers, i downgrade to 16.0.0 and then worked
Solution 24:[24]
Regarding npx ...
If you have create-react-app (CRA) globally installed;
it is recommend you uninstall CRA
to ensure that npx always uses the latest version.
When using npx, the global installation isn't used.
But it may interfere (addressed below).
Don't run your React app from your desktop.
Some operating systems may throw an error.
Windows OS users ...
As administrator (for steps #1 & #2), inside your command-line ...
1) uninstall your global version of CRA.
npm uninstall -g create-react-app Mac prefix: sudo
2) Then ...
Run: npx create-react-app my-app Mac prefix: sudo
Above: This will create the latest version of
a React app named: my-app.
This app will be created wherever your command-line is pointing.
3) Open Google Chrome.
4) cd my-app (point your command-line to your project folder).
5) inside your command-line ... Run: npm start
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow