Unexpected end of JSON input while parsing near错误探究 开发手记 2019-06-18

2019/06/18 13:49 下午 comments

今天使用npm install的时候发现了一个很神奇的错误。

3098 silly saveTree ├── [email protected]
3098 silly saveTree ├── [email protected]
3098 silly saveTree └── [email protected]
3099 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...{"react":">=16.0.0","'
3099 verbose stack     at JSON.parse (<anonymous>)
3099 verbose stack     at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
3099 verbose stack     at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
3099 verbose stack     at process.internalTickCallback (internal/process/next_tick.js:77:7)
3100 verbose cwd /Users/ZNing/OfflineProgramming/oeup06
3101 verbose Darwin 18.6.0
3102 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
3103 verbose node v11.0.0
3104 verbose npm  v6.9.0
3105 error Unexpected end of JSON input while parsing near '...{"react":">=16.0.0","'
3106 verbose exit [ 1, true ]

从网上先搜到了解决方法了,运行:

npm cache clean --force

这句话是强行将npm所下缓存文件全部强制清除,但是不知道这个玩意是为什么导致这个问题的。

先留个坑,回头补一下。

参考文献

  1. https://blog.csdn.net/m0_37836194/article/details/79107785