每次拉新項(xiàng)目安裝依賴的時(shí)候搂橙,總是會(huì)報(bào)各種各樣的錯(cuò)誤
npm install
一開(kāi)始還以為是哪個(gè)文件有問(wèn)題,后來(lái)明白了笛坦,一切都是因?yàn)榫W(wǎng)絡(luò)区转。。版扩。废离。
npm 默認(rèn)連接的服務(wù)器是國(guó)外的,網(wǎng)絡(luò)很不穩(wěn)定礁芦。厅缺。。宴偿。所以極其容易出錯(cuò)
后來(lái)每次換電腦湘捎,我都會(huì)直接將npm連接的服務(wù)器設(shè)置為淘寶源(淘寶架設(shè)的與npm官方同步數(shù)據(jù)的服務(wù)器)國(guó)內(nèi)訪問(wèn)絲滑流暢
npm config set registry https://registry.npm.taobao.org
可是后來(lái)還是遇到了問(wèn)題
仔細(xì)看報(bào)錯(cuò)信息,是node-sass下載失敗了窄刘。
我以為是node-sass版本問(wèn)題窥妇,后來(lái)以為是node的版本問(wèn)題(node太新的話,不兼容老版本node-sass)
但我還是栽了娩践。活翩。。翻伺。材泄。,它依然還是網(wǎng)絡(luò)問(wèn)題6至搿@凇!
仔細(xì)看下面安裝Node-sass時(shí)的報(bào)錯(cuò)信息
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-72_binding.node":
HTTP error 404 Not Found
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
發(fā)現(xiàn)沒(méi)有
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-72_binding.node":
無(wú)法下載,地址是什么旦事? https://github.com/
回憶一下魁巩,我們平時(shí)上gayhub時(shí)的卡頓酸爽?
是的姐浮,node-sass在安裝過(guò)程中谷遂,有一步是下載win32-x64-72_binding.node這個(gè)文件,而它請(qǐng)求的是github地址卖鲤,所以我們現(xiàn)在要把這個(gè)地址也替換成淘寶源
npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
設(shè)置好以后肾扰,我們進(jìn)行
npm install
大功告成!(看Downloading的地址是不是變成了taobao.org)
Downloading binary from https://npm.taobao.org/mirrors/node-sass/v4.13.1/win32-x64-72_binding.node
Download complete ] - :
Binary saved to E:\project\nj-mc-poc-pc\node_modules\node-sass\vendor\win32-x64-72\binding.node
Caching binary to C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.13.1\win32-x64-72_binding.node
> node-sass@4.13.1 postinstall E:\project\nj-mc-poc-pc\node_modules\node-sass
> node scripts/build.js
Binary found at E:\project\nj-mc-poc-pc\node_modules\node-sass\vendor\win32-x64-72\binding.node
Testing binary
Binary is fine
npm WARN script-ext-html-webpack-plugin@2.0.1 requires a peer of html-webpack-plugin@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-g2@1.2.4 requires a peer of @antv/data-set@^0.9.6 but none is installed. You must install peer dependencies yourself.
npm WARN vue-admin-template@3.8.0 No repository field.
+ node-sass@4.13.1
added 84 packages from 92 contributors in 23.394s
28 packages are looking for funding
run `npm fund` for details
綜合起來(lái)就是
npm config set registry https://registry.npm.taobao.org
npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
npm install
不是我針對(duì)誰(shuí)蛋逾,在座的報(bào)錯(cuò)集晚,都是垃圾!;徊馈!