0

我试图在 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 ]

任何建议,将不胜感激。

4

1 回答 1

3

我遇到了同样的错误,在搜索时我发现我需要先清除 npm 缓存,确实有效。首先运行以下命令:

npm cache clean --force

然后运行那个 react-native 命令,它会很有希望地工作。

于 2018-06-26T12:41:57.260 回答