vue项目报错,解决Module build failed: Error: Cannot find module node-sass 问题

1年前 (2023) 程序员胖胖胖虎阿
120 0 0
1、报错问题
1
E:\WebStormFile\treehole-manage>npm run dev 2 > xc-ui-pc-sysmanage@1.0.0 dev E:\WebStormFile\treehole-manage 3 > webpack-dev-server --inline --progress --config build/webpack.dev.conf.js 4 94% asset optimization 5 ERROR Failed to compile with 2 errors 09:51:14 6 7 error in ./src/base/components/head.vue 8 9 Module build failed: Error: Cannot find module 'node-sass' 10 at Function.Module._resolveFilename (module.js:547:15) 11 at Function.Module._load (module.js:474:25) 12 at Module.require (module.js:596:17) 13 at require (internal/module.js:11:18) 14 at Object.<anonymous> (E:\WebStormFile\treehole-manage\node_modules\sass-loader\lib\loader.js:3:14) 15 at Module._compile (module.js:652:30) 16 at Object.Module._extensions..js (module.js:663:10) 17 at Module.load (module.js:565:32) 18 at tryModuleLoad (module.js:505:12) 19 at Function.Module._load (module.js:497:3) 20 at Module.require (module.js:596:17) 21 at require (internal/module.js:11:18) 22 at loadLoader (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\loadLoader.js:13:17) 23 at iteratePitchingLoaders (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:1 24 69:2) 25 at iteratePitchingLoaders (E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:1 26 65:10) 27 at E:\WebStormFile\treehole-manage\node_modules\loader-runner\lib\LoaderRunner.js:173:18 28 29 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/ 30 style-compiler?{"vue":true,"id":"data-v-1340bee1","scoped":true,"hasInlineConfig":false}!./node_modules/sass-lo 31 ader/lib/loader.js?{"sourceMap":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache! 32 ./src/base/components/head.vue 4:14-395 13:3-17:5 14:22-403 33 @ ./src/base/components/head.vue 34 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./sr 35 c/module/home/page/home.vue 36 @ ./src/module/home/page/home.vue 37 @ ./src/module/home/router/index.js 38 @ ./src/base/router/index.js 39 @ ./src/main.js 40 @ multi (webpack)-dev-server/client?http://localhost:11001 webpack/hot/dev-server ./src/main.js 41
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’
vue项目报错,解决Module build failed: Error: Cannot find module node-sass 问题
3)cnpm install node-sass --save,使用cnpm重新下载‘node-sass’文件
vue项目报错,解决Module build failed: Error: Cannot find module node-sass 问题
4)npm run dev ,重新运行项目。
vue项目报错,解决Module build failed: Error: Cannot find module node-sass 问题

 

相关文章

暂无评论

暂无评论...