npm ERR! Unexpected token in JSON at position 1 while parsing near

執行npm 任何命令報錯

PS C:\WINDOWS\system32> npm install vue-cli -g
npm ERR! Unexpected token < in JSON at position 1 while parsing near '
npm ERR! <!doctype html>
npm ERR! <htm...'

npm ERR! A complete log of this run can be found in:

報錯如下圖: npm ERR! Unexpected token in JSON at position 1 while parsing near
原因:
這種問題一般是由於網絡原因導致下載的某些依賴的文件損壞,可以使用淘寶NPM鏡像,設置方法爲:

npm config set registry https://registry.npm.taobao.org

設置完成後,重新執行

發佈了53 篇原創文章 · 獲贊 15 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章