npm install報錯Unexpected end of JSON input while parsing near '...ersion":"4.5.0","depe'

這兩天執行 npm install 時會報錯誤:

17971 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ersion":"4.5.0","depe'
17971 verbose stack     at JSON.parse (<anonymous>)
17971 verbose stack     at parseJson (C:\Users\Administrator.CE-20151109NQJC\AppData\Roaming\npm\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
17971 verbose stack     at C:\Users\Administrator.CE-20151109NQJC\AppData\Roaming\npm\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
17971 verbose stack     at runMicrotasks (<anonymous>)
17971 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:94:5)
17972 verbose cwd E:\workspaces\multiplatform
17973 verbose Windows_NT 6.1.7601
17974 verbose argv "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Administrator.CE-20151109NQJC\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
17975 verbose node v12.14.1
17976 verbose npm  v6.13.6
17977 error Unexpected end of JSON input while parsing near '...ersion":"4.5.0","depe'
17978 verbose exit [ 1, true ]

這個錯誤的解決方法有以下幾種:

1.刪掉package.lock.json

2.清除cache

npm cache clean --force

3.進入下面這個文件夾清除cache
路徑:C:/Users/PC/AppData/Roaming/npm-cache
執行:

npm cache clean --force

4.不要用淘寶鏡像。

npm set registry https://registry.npmjs.org/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章