Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facing error while installing firebase via npm | Unexpected end of JSON input while parsing near [closed]

I am trying to install firebase in my fresh react project, I could not able to install it.

Whether it is an error or the npm is taking time. I am waiting for more than half an hour.

enter image description here enter image description here

like image 466
VnoitKumar Avatar asked Sep 14 '19 17:09

VnoitKumar


2 Answers

Try this (you may need to run sudo or if you're on Windows, open cmd as Admin)..

npm cache clean --force

then run

npm install firebase
like image 140
Matt Oestreich Avatar answered Nov 17 '22 21:11

Matt Oestreich


while the above answer seems to work for most cases it wasn't true for my case. I tried

npm cache clean -f
npm install firebase

no luck!

I followed this thread which explained a lot about npm caches which also concluded the above method should work and maybe to just verify cache before installing firebase

   npm cache clean -f
   npm install firebase
   npm verify cache

still, no luck so I just decided to add it in package.json as a dependency with the latest stable version of firebase (8.0.0) at this time.

so go to package.json file and in the dependencies section

"dependencies": {
     "firebase": "^8.0.0",
     ...other dependencies
     }

and do

npm cache clean -f
npm install npm@latest

this should work for similar cases check out this link to see how caching on npm works in detail.

like image 39
Azaria Gebremichael Avatar answered Nov 17 '22 23:11

Azaria Gebremichael