4

I have used firebase right up to yesterday morning, then suddenly in the afternoon "npm install --save firebase" stopped working with the error:

npm ERR! Unexpected end of JSON input while parsing near '...anary.9678bf9.tgz","f'

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\manjot\AppData\Roaming\npm-cache_logs\2019-11-04T05_47_36_550Z-debug.log

I've tried updating my node.js from 10 to 13.0.1, uninstalling and installing, clearing cache, restarting my computer, a new project, doing all of this with admin cmd, googled a bit but no luck so far. Why did it suddenly stop working and how to fix this issue? I can still do things like

"npm install --save react-navigation"

or

"npm install --save react-navigation-stack"

Deep Kakkar
  • 5,831
  • 4
  • 39
  • 75
  • try once npm audit fix. It will scan your project for vulnerabilities and automatically install any compatible updates to vulnerable dependencies. – Deep Kakkar Nov 04 '19 at 05:59

2 Answers2

5

Looks like the latest released version of firebase npm module is corrupted somehow and npm is failing to parse the tgz file for the lib. If it was me I would go and look at their releases page look for a previous version you know works and install that version.

npm install firebase@x.y.z for example

I would also say, be sure to use a package-lock.json file to lock down working versions of modules.

Tyrone Wilson
  • 4,328
  • 2
  • 31
  • 35
-1

The same problem happened to me one day.

  • Delete the npm_modules directory

  • run npm install command

It worked for me!

Dev Matee
  • 5,525
  • 2
  • 27
  • 33