Search code examples
node.jsnpmsurge.sh

Unable to install Surge


I'm trying to install surge via npm using the command

npm install -g surge

But it's throwing the following error

npm ERR! Unexpected end of JSON input while parsing near '...<2.0.0","ecc-jsbn":">'

npm ERR! A complete log of this run can be found in: npm ERR! /.npm/_logs/2019-09-28T07_05_28_294Z-debug.log

Any clues on the following?

Upon checking the log files, the following is seen (Sorry for the massive log)

>0 info it worked if it ends with ok
>1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'surge' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 5401a8f4e3b6d38a
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/surge 317ms (from cache)
8 silly pacote tag manifest for surge@latest fetched in 360ms
9 timing stage:loadCurrentTree Completed in 395ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule [email protected] checking installable status
17 http fetch GET 304 https://registry.npmjs.org/cli-table3 97ms (from cache)
18 silly pacote range manifest for cli-table3@^0.5.1 fetched in 108ms
19 silly resolveWithNewModule [email protected] checking installable status
20 http fetch GET 304 https://registry.npmjs.org/request 73ms (from cache)
21 silly pacote range manifest for request@^2.88.0 fetched in 86ms
22 silly resolveWithNewModule [email protected] checking installable status
23 http fetch GET 304 https://registry.npmjs.org/netrc 223ms (from cache)

....

 329 silly pacote range manifest for safe-buffer@^5.1.2 fetched in 98ms
    330 silly resolveWithNewModule [email protected] checking installable status
    331 silly pacote range manifest for uuid@^3.3.2 fetched in 93ms
    332 silly resolveWithNewModule [email protected] checking installable status
    333 http fetch GET 304 https://registry.npmjs.org/delayed-stream 65ms (from cache)
    334 silly pacote range manifest for delayed-stream@~1.0.0 fetched in 69ms
    335 silly resolveWithNewModule [email protected] checking installable status
    336 http fetch GET 304 https://registry.npmjs.org/asynckit 69ms (from cache)
    337 silly pacote range manifest for asynckit@^0.4.0 fetched in 71ms
    338 silly resolveWithNewModule [email protected] checking installable status
    339 http fetch GET 304 https://registry.npmjs.org/mime-db 71ms (from cache)
    340 silly pacote version manifest for [email protected] fetched in 75ms
    341 silly resolveWithNewModule [email protected] checking installable status
    342 http fetch GET 304 https://registry.npmjs.org/har-schema 76ms (from cache)
    343 silly pacote range manifest for har-schema@^2.0.0 fetched in 81ms
    344 silly resolveWithNewModule [email protected] checking installable status
    345 http fetch GET 304 https://registry.npmjs.org/ajv 114ms (from cache)
    346 silly pacote range manifest for ajv@^6.5.5 fetched in 124ms
    347 silly resolveWithNewModule [email protected] checking installable status
    348 http fetch GET 304 https://registry.npmjs.org/json-schema-traverse 74ms (from cache)
    349 http fetch GET 304 https://registry.npmjs.org/fast-json-stable-stringify 76ms (from cache)
    350 http fetch GET 304 https://registry.npmjs.org/uri-js 76ms (from cache)
    351 silly pacote range manifest for json-schema-traverse@^0.4.1 fetched in 77ms
    352 silly resolveWithNewModule [email protected] checking installable status
    353 silly pacote range manifest for fast-json-stable-stringify@^2.0.0 fetched in 82ms
    354 silly resolveWithNewModule [email protected] checking installable status
    355 silly pacote range manifest for uri-js@^4.2.2 fetched in 81ms
    356 silly resolveWithNewModule [email protected] checking installable status
    357 http fetch GET 304 https://registry.npmjs.org/fast-deep-equal 84ms (from cache)
    358 silly pacote range manifest for fast-deep-equal@^2.0.1 fetched in 85ms
    359 silly resolveWithNewModule [email protected] checking installable status
    360 http fetch GET 304 https://registry.npmjs.org/punycode 86ms (from cache)
    361 silly pacote range manifest for punycode@^2.1.0 fetched in 89ms
    362 silly resolveWithNewModule [email protected] checking installable status
    363 http fetch GET 304 https://registry.npmjs.org/assert-plus 75ms (from cache)
    364 silly pacote range manifest for assert-plus@^1.0.0 fetched in 77ms
    365 silly resolveWithNewModule [email protected] checking installable status
    366 http fetch GET 304 https://registry.npmjs.org/jsprim 78ms (from cache)
    367 http fetch GET 304 https://registry.npmjs.org/sshpk 78ms (from cache)
    368 silly fetchPackageMetaData error for sshpk@^1.7.0 Unexpected end of JSON input while parsing near '...<2.0.0","ecc-jsbn":">'
    369 silly pacote range manifest for jsprim@^1.2.2 fetched in 81ms
    370 silly resolveWithNewModule [email protected] checking installable status
    371 timing stage:rollbackFailedOptional Completed in 1ms
    372 timing stage:runTopLevelLifecycles Completed in 4344ms
    373 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...<2.0.0","ecc-jsbn":">'
    373 verbose stack     at JSON.parse (<anonymous>)
    373 verbose stack     at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
    373 verbose stack     at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
    373 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
    374 verbose cwd /Users/ym
    375 verbose Darwin 18.7.0
    376 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "surge"
    377 verbose node v10.16.3
    378 verbose npm  v6.9.0
    379 error Unexpected end of JSON input while parsing near '...<2.0.0","ecc-jsbn":">'
    380 verbose exit [ 1, true ]

Solution

  • Npm uses Cache for downloading new packages for you. You need to clear your npm cache. use following command to clean :

    open the terminal as admin

    npm uninstall -g surge
    npm cache clean --force
    

    then run

    npm install -g surge
    

    this work for me!

    in some time seems like there was just a download error and you should try again for install this.

    This has not worked in my case! Pls provide any other options. Thanks.