報錯信息:node
npm WARN sass-loader@8.0.0 requires a peer of webpack@^4.36.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.0 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.0 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})webpack
從報錯來看,應該是loader的問題,而後就刪除重裝sass-loader,node-sass,來來回回不下5次,仍是報一樣的錯誤,甚至懷疑是否是webpack.dev.config.js中沒有配置好?一步步檢查,也沒有發現問題。git
npm install node-sass --save-dev //安裝node-sass
npm install sass-loader --save-dev //安裝sass-loader
npm install style-loader --save-dev //安裝style-loaderweb
最後換git bash 來從新執行了一邊npm install 代碼,這個時候發現了問題…… ,因爲以前我都是直接在vsCode中直接新建終端來執行shell腳本的,界面比較小,因此沒有顯示完整的日誌,此次終於發現了蹊蹺。shell
這是由於當前sass的版本過高,webpack編譯時出現了錯誤,這個時候只須要換成低版本的就行,下面說一下修改方法,很簡單,以下,找到package.json文件,裏面的 "sass-loader"的版本更換掉 就好了。npm
我本地是將 "sass-loader": "^8.0.0",更換成了 "sass-loader": "^7.3.1"。json
卸載當前版本sass-loader命令:npm uninstall sass-loader sass
安裝低版本的sass-loader命令:npm install sass-loader@7.3.1 --save-devbash