Search code examples
htmlnpmng2-smart-table

Unexpected end of json when installing npm package


Im trying to run npm install on ng2-smart-table. It looks like its having trouble getting some of the modules. Im getting the following error.

    npm ERR! Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tommie/.npm/_logs/2018-05-15T14_32_04_066Z-debug.log
Tommies-MacBook-Pro:ng2-smart-table tommie$ vi /Users/tommie/.npm/_logs/2018-05-15T14_32_04_066Z-debug.log
Tommies-MacBook-Pro:ng2-smart-table tommie$ rm package-lock.json
rm: package-lock.json: No such file or directory

When I look at the log I get the following

<snip>
4508 silly pacote range manifest for http-proxy-middleware@~0.17.4 fetched in 16ms
4509 silly resolveWithNewModule http-proxy-middleware@0.17.4 checking installable status
4510 silly pacote version manifest for sockjs@0.3.18 fetched in 16ms
4511 silly resolveWithNewModule sockjs@0.3.18 checking installable status
4512 silly pacote version manifest for sockjs-client@1.1.2 fetched in 17ms
4513 silly resolveWithNewModule sockjs-client@1.1.2 checking installable status
4514 silly pacote range manifest for yargs@^6.0.0 fetched in 3ms
4515 silly resolveWithNewModule yargs@6.6.0 checking installable status
4516 http fetch GET 304 https://registry.npmjs.org/spdy 33ms (from cache)
4517 silly fetchPackageMetaData error for spdy@^3.4.1 Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4518 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4518 verbose stack     at JSON.parse (<anonymous>)
4518 verbose stack     at parseJson (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/node_modules/json-parse-better-errors/index.js:7:17)
4518 verbose stack     at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:96:50)
4518 verbose stack     at <anonymous>
4518 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)
4519 verbose cwd /Users/tommie/dev/ng2-smart-table
4520 verbose Darwin 15.6.0
4521 verbose argv "/usr/local/Cellar/node/8.2.1/bin/node" "/usr/local/bin/npm" "install"
4522 verbose node v8.2.1
4523 verbose npm  v5.4.0
4524 error Unexpected end of JSON input while parsing near '..."spdy","version":"1.1'
4525 verbose exit [ 1, true ]

Any suggestions would be appreciated.


Solution

  • I got the same error and on searching I found out I needed to clear the npm cache first, did and it worked. first run the following command:

    npm cache clean --force
    

    And then run that react-native command, it will work hopefully.