npm ERR! Unexpected end of JSON input

今天npm提示可以更新:

  ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.6.0 → 5.7.1    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯

执行了一下,发现报错

➜  ~ ✗ npm i -g npm
npm ERR! Unexpected end of JSON input while parsing near '...ist":{"shasum":"b779a'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2018-03-15T05_56_22_902Z-debug.log

于是清理了一下cache,再执行,成功

➜  ~ ✗ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
➜  ~ ✗ sudo npm i -g npm
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
+ [email protected]
added 63 packages, removed 6 packages and updated 49 packages in 17.184s

猜你喜欢

转载自my.oschina.net/u/2935389/blog/1635131