①git
鏡像使用方法(三種辦法任意一種都能解決問題,建議使用第三種,將配置寫死,下次用的時候配置還在):github
1.經過config命令express
npm config set registry https://registry.npm.taobao.org npm info underscore (若是上面配置正確這個命令會有字符串response)
2.命令行指定npm
npm --registry https://registry.npm.taobao.org info underscore
3.編輯 ~/.npmrc
加入下面內容spa
registry = https://registry.npm.taobao.org
搜索鏡像: https://npm.taobao.org命令行
創建或使用鏡像,參考: https://github.com/cnpm/cnpmjs.orgcode
有不少方法來配置npm
的registry地址,下面根據不一樣情境列出幾種比較經常使用的方法。以淘寶npm
鏡像舉例:字符串
npm --registry https://registry.npm.taobao.org install express
npm config set registry https://registry.npm.taobao.org // 配置後可經過下面方式來驗證是否成功 npm config get registry // 或 npm info express
cnpm
使用npm install -g cnpm --registry=https://registry.npm.taobao.org // 使用 cnpm install express
yarn設置淘寶鏡像underscore
$ yarn config set registry https://registry.npm.taobao.org yarn config v1.6.0 success Set "registry" to "https://registry.npm.taobao.org". Done in 0.04s.