Firebase-admin-node: npm i --save firebase-admin "error Unexpected end of JSON input while parsing near"

Created on 29 May 2018  路  6Comments  路  Source: firebase/firebase-admin-node

Cannot install firebase-admin-node suddenly

I have used this package previously on:

  • Ubuntu 16.04,
  • Node 8.9.1,
  • NPM 5.5.1

I am setting up a new environment right now with:

  • Ubuntu 16.04
  • Node 10.2.1
  • NPM 6.1.0

I keep getting this error -
Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'

I was skeptical if it had something to do with old package-lock file or node_modules dir. So I created a brand new empty directory and tested; ended up with the exact same error.

Here's the complete log of the run:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli   '/usr/bin/npm',
1 verbose cli   'i',
1 verbose cli   '--save',
1 verbose cli   'firebase-admin' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 84906059a65735f6
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/firebase-admin 23ms (from cache)
8 silly pacote tag manifest for firebase-admin@latest fetched in 64ms
9 timing stage:loadCurrentTree Completed in 263ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 0ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule [email protected] checking installable status
17 http fetch GET 200 https://registry.npmjs.org/node-forge 70ms (from cache)
18 http fetch GET 200 https://registry.npmjs.org/jsonwebtoken 75ms (from cache)
19 silly pacote version manifest for [email protected] fetched in 78ms
20 silly resolveWithNewModule [email protected] checking installable status
21 silly pacote version manifest for [email protected] fetched in 76ms
22 silly resolveWithNewModule [email protected] checking installable status
23 http fetch GET 304 https://registry.npmjs.org/@types%2fgoogle-cloud__storage 1396ms (from cache)
24 silly pacote range manifest for @types/google-cloud__storage@^1.1.7 fetched in 1408ms
25 silly resolveWithNewModule @types/[email protected] checking installable status
26 http fetch GET 304 https://registry.npmjs.org/@firebase%2fapp 1422ms (from cache)
27 silly pacote range manifest for @firebase/app@^0.1.10 fetched in 1434ms
28 silly resolveWithNewModule @firebase/[email protected] checking installable status
29 http fetch GET 304 https://registry.npmjs.org/@google-cloud%2ffirestore 1436ms (from cache)
30 silly pacote range manifest for @google-cloud/firestore@^0.14.0 fetched in 1441ms
31 silly resolveWithNewModule @google-cloud/[email protected] checking installable status
32 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 1440ms (from cache)
33 silly pacote range manifest for @types/node@^8.0.53 fetched in 1447ms
34 silly resolveWithNewModule @types/[email protected] checking installable status
35 http fetch GET 304 https://registry.npmjs.org/@firebase%2fdatabase 1451ms (from cache)
36 silly pacote range manifest for @firebase/database@^0.2.0 fetched in 1462ms
37 silly resolveWithNewModule @firebase/[email protected] checking installable status
38 http fetch GET 304 https://registry.npmjs.org/@google-cloud%2fstorage 1593ms (from cache)
39 silly pacote range manifest for @google-cloud/storage@^1.6.0 fetched in 1596ms
40 silly resolveWithNewModule @google-cloud/[email protected] checking installable status
41 http fetch GET 200 https://registry.npmjs.org/tslib 10ms (from cache)
42 silly pacote range manifest for tslib@^1.9.0 fetched in 14ms
43 silly resolveWithNewModule [email protected] checking installable status
44 http fetch GET 304 https://registry.npmjs.org/@firebase%2futil 1231ms (from cache)
45 silly pacote version manifest for @firebase/[email protected] fetched in 1236ms
46 silly resolveWithNewModule @firebase/[email protected] checking installable status
47 http fetch GET 304 https://registry.npmjs.org/@firebase%2fapp-types 1281ms (from cache)
48 silly fetchPackageMetaData error for @firebase/[email protected] Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'
49 timing stage:rollbackFailedOptional Completed in 1ms
50 timing stage:runTopLevelLifecycles Completed in 3168ms
51 silly saveTree tesFolder
51 silly saveTree `-- [email protected]
51 silly saveTree   +-- @firebase/[email protected]
51 silly saveTree   | +-- @firebase/[email protected]
51 silly saveTree   | | `-- [email protected]
51 silly saveTree   | `-- [email protected]
51 silly saveTree   +-- @firebase/[email protected]
51 silly saveTree   +-- @google-cloud/[email protected]
51 silly saveTree   +-- @google-cloud/[email protected]
51 silly saveTree   +-- @types/[email protected]
51 silly saveTree   | `-- @types/[email protected]
51 silly saveTree   +-- @types/[email protected]
51 silly saveTree   +-- [email protected]
51 silly saveTree   `-- [email protected]
52 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'
52 verbose stack     at JSON.parse (<anonymous>)
52 verbose stack     at parseJson (/usr/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
52 verbose stack     at consumeBody.call.then.buffer (/usr/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:96:50)
52 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
53 verbose cwd /home/$USER/tesFolder
54 verbose Linux 4.13.0-43-generic
55 verbose argv "/usr/bin/node" "/usr/bin/npm" "i" "--save" "firebase-admin"
56 verbose node v10.2.1
57 verbose npm  v6.1.0
58 error Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'
59 verbose exit [ 1, true ]

Most helpful comment

Installs fine for me. I think your local npm cache is corrupted:

47 http fetch GET 304 https://registry.npmjs.org/@firebase%2fapp-types 1281ms (from cache)
48 silly fetchPackageMetaData error for @firebase/[email protected] Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'

Try clearing the cache: https://docs.npmjs.com/troubleshooting/try-clearing-the-npm-cache

All 6 comments

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

Installs fine for me. I think your local npm cache is corrupted:

47 http fetch GET 304 https://registry.npmjs.org/@firebase%2fapp-types 1281ms (from cache)
48 silly fetchPackageMetaData error for @firebase/[email protected] Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'

Try clearing the cache: https://docs.npmjs.com/troubleshooting/try-clearing-the-npm-cache

Had to use the above command with --force and it installs. Thanks

npm cache's claim:

All data that passes through the cache is fully verified for integrity on both insertion and extraction. Cache corruption will either trigger an error, or signal to pacote that the data must be refetched, which it will do automatically. For this reason, it should never be necessary to clear the cache for any reason other than reclaiming disk space, thus why clean now requires --force to run.

The npm cache is strictly a cache: it should not be relied upon as a persistent and reliable data store for package data. npm makes no guarantee that a previously-cached piece of data will be available later, and will automatically delete corrupted contents. The primary guarantee that the cache makes is that, if it does return data, that data will be exactly the data that was inserted.

But based on several issues (pretty common I guess), npm cache's "corruption-proof" seem to be just assumptions, not reality. :'(

Installs fine for me. I think your local npm cache is corrupted:

47 http fetch GET 304 https://registry.npmjs.org/@firebase%2fapp-types 1281ms (from cache)
48 silly fetchPackageMetaData error for @firebase/[email protected] Unexpected end of JSON input while parsing near '...yO+bxm7E0cwHbOkBOoI5N'

Try clearing the cache: https://docs.npmjs.com/troubleshooting/try-clearing-the-npm-cache

thanks, It is working
clear your npm cache by the following command
npm cache clean --force
then npm i --save firebase-admin

Was this page helpful?
0 / 5 - 0 ratings