1、报错问题
1 E:\WebStormFile\treehole-manage>npm run dev
> xc-ui-pc-sysmanage@1.0.0 dev E:\WebStormFile\treehole-manage
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
94% asset optimization
ERROR Failed to compile with 2 errors 09:51:14
error in ./src/base/components/head.vue
Module build failed: Error: Cannot find module 'node-sass'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (E:\WebStormFile\treehole-manage\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at loadLoader (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\loadLoader.js:13:17)
at iteratePitchingLoaders (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:1
69:2)
at iteratePitchingLoaders (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:1
65:10)
at E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:173:18
@ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/
style-compiler?{"vue":true,"id":"data-v-1340bee1","scoped":true,"hasInlineConfig":false}!./node_modules/sass-lo
ader/lib/loader.js?{"sourceMap":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache!
./src/base/components/head.vue 4:14-395 13:3-17:5 14:22-403
@ ./src/base/components/head.vue
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./sr
c/module/home/page/home.vue
@ ./src/module/home/page/home.vue
@ ./src/module/home/router/index.js
@ ./src/base/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:11001 webpack/hot/dev-server ./src/main.js
2、解决过程
1)使用命令“npm install node-sass --save-dev”下载一个新的 “node-sass”文件
“Module build failed: Error: Cannot find module 'node-sass'”的意思是找不到模块的‘node-sass’文件,所以你要做的是去下载一个‘node-sass’文件,好吧,报错了。仔细看了一下,并借鉴 https://blog.csdn.net/qq_38401285/article/details/86483278 这个博主踩的坑,然后我直接做了第二步。
E:\WebStormFile\treehole-manage>npm install node-sass --save-dev
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npm.taobao.org/node-sass failed, reason: connect ECONNREFUSED 127.0.0.1:1080
npm ERR! at ClientRequest.req.on.err (E:\WebStormFile\treehole-manage\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_mo
.......
npm ERR! at <anonymous>
npm ERR! at process._tickCallback (internal/process/next_tick.js:188:7)
npm ERR! message: 'request to https://registry.npm.taobao.org/node-sass failed, reason: connect ECONNREFUSED 127.0.0.1:1080',
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! stack: 'FetchError: request to https://registry.npm.taobao.org/node-sass failed, reason: connect ECONNREFUSED 127.0.0.1:1080\n at Clien
.......
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'
+++》意思大概是 如果你在一个代理后面,请确保npm出错了代理服务器的配置设置正确。
.......
2)npm配置使用淘宝镜像 ‘npm config set registry http://registry.npm.taobao.org’
3)cnpm install node-sass --save,使用cnpm重新下载‘node-sass’文件
4)npm run dev ,重新运行项目。