npm install 報錯 彙總
阿新 • • 發佈:2019-02-01
1、npm install 報錯:
1.NPM Unexpected end of JSON input while parsing near
2.npm ERR! A complete log of this run can be found in:
解決辦法:
首先:
更新npm版本命令:
npm install npm -g 要記住全域性更新
淘寶映象命令:cnpm install npm -g 淘寶映象會比較快
再檢視一下npm版本:npm -v
其次:
npm install --registry=https://registry.npm.taobao.org --loglevel=silly:
最後:
npm cache clean --force
2、npm下載失敗?
解決方案:修改npm映象源。
修改npm映象源方法(三種辦法任意一種都能解決問題,建議使用第三種,將配置寫死,下次用的時候配置還在):
1.通過config命令
npm config set registry https://registry.npm.taobao.org
npm info underscore (如果上面配置正確這個命令會有字串response)
2.命令列指定
npm --registry https://registry.npm.taobao.org info underscore
3.編輯 ~/.npmrc
加入下面內容
registry = https://registry.npm.taobao.org
Mac系統下,.npmrc這樣設定:
開啟終端,切換到根路徑
一、open .npmrc(會提示找不到該檔案,沒關係)
二、npm config set registry https://registry.npm.taobao.org
三、再次跳到步驟一,就能看到npmrc檔案中已經設定好了registry
(宣告:本文參考網路上的解決方案)