tl;dr
- npm install -g @vue/cli でエラーが発生
- npm cache clean --forceで解決した
- 再び、npm install -g @vue/cli で無事にインストールができた
エラー内容
npm ERR! Unexpected end of JSON input while parsing near '...XAWVO\n+/4j+zc2nz6uaW'
発生の状況
npm install -g @vue/cli を実行
npm install -g @vue/cli を実行したところ、下記のエラーが発生
npm ERR! Unexpected end of JSON input while parsing near '.........'
解決までの過程
Unexpected end of JSON input while parsing near で検索
Unexpected end of JSON input while parsing near で検索したところ、下記のissueにたどり着いた
npm cache clean --forceで解決したというコメントがあった
下記のコメントがあったのでnpm cache clean --forceコマンドを実行した。
npm cache clean --force that solved
解決策
npm cache clean --forceを実行し、npm install -g @vue/cliを実行すると正常に終わった
キャッシュされているファイルが破損していたために起きたようでした。
npm cache clean --forceでキャッシュを削除し再度npm install -g @vue/cli実行することで解決に至りました。