Reputation: 329
I'm using Ubuntu 20.04. I've been trying to run create react app using npx for over 2 days switching to different Wifis + Ethernet but I get Invalid json response body at https://registry.npmjs.org/loose-envify
all the time.
I thought it was an internet speed connection problem but it wasn't
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/loose-envify reason: Unexpected end of JSON input
npm ERR! A complete log of this run can be found in:
npm ERR! /home/deestarks/.npm/_logs/2021-04-12T18_55_27_266Z-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
Upvotes: 1
Views: 1774
Reputation: 601
I had and resolved similar issue here: npm install failed, npm ERR! invalid json response
npm cache clean --force
and
npm cache verify
then
npm i npm@latest -g
and finally, I was able to run
npm i
The similar question was there: npm ERR! Unexpected end of JSON input while parsing near '...registry.npmjs.org/@i'
Upvotes: 1
Reputation: 21
run this command and it will solve your issue
sudo npm cache clean --force
Upvotes: 0