我试图在ng2-smart-table上运行npm install。看起来它在获取某些模块时遇到了麻烦。我得到以下错误。
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
当我查看日志时,我得到以下内容
<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 ]
任何建议都将不胜感激。
答案 0 :(得分:1)
我遇到了同样的错误,在搜索时发现我需要先清除npm缓存,这样做并能正常工作。 首先运行以下命令:
npm cache clean --force
然后运行该react-native命令,它将有望运行。