Module build failed: Error: Cannot find module 'node-sass’解决
Posted mfbzr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Module build failed: Error: Cannot find module 'node-sass’解决相关的知识,希望对你有一定的参考价值。
在 npm run dev 时出现 ” Module build failed: Error: Cannot find module ‘node-sass’ “ 这样的错误,如下:
ERROR Failed to compile with 1 errors 19:51:09 error in ./src/page/Class/ClassList.vue Module build failed: Error: Cannot find module ‘node-sass‘ Require stack: - F:Workspacevscodeuser_h5 ode_modulessass-loaderlibloader.js - F:Workspacevscodeuser_h5 ode_modulesloader-runnerlibloadLoader.js - F:Workspacevscodeuser_h5 ode_modulesloader-runnerlibLoaderRunner.js - F:Workspacevscodeuser_h5 ode_moduleswebpacklibNormalModule.js - F:Workspacevscodeuser_h5 ode_moduleswebpacklibNormalModuleFactory.js - F:Workspacevscodeuser_h5 ode_moduleswebpacklibCompiler.js - F:Workspacevscodeuser_h5 ode_moduleswebpacklibwebpack.js - F:Workspacevscodeuser_h5 ode_moduleswebpack-dev-serverlibServer.js - F:Workspacevscodeuser_h5 ode_moduleswebpack-dev-serverinwebpack-dev-server.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17) at Function.Module._load (internal/modules/cjs/loader.js:686:27) at Module.require (internal/modules/cjs/loader.js:848:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.sassLoader (F:Workspacevscodeuser_h5 ode_modulessass-loaderlibloader.js:46:72) @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-63ab3a78","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false}!./node_modules/vux-loader/src/style-loader.js!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/page/Class/ClassList.vue 4:14-443 13:3-17:5 14:22-451 @ ./src/page/Class/ClassList.vue @ ./src/router/index.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
解决:
1.下载 node-sass 依赖
npm install node-sass --save-dev
还是报错
2.输入命令
npm install -g cnpm --registry=https://registry.npm.taobao.org
报错如下:
cnpm - 解决 " cnpm : 无法加载文件 C:Users93457AppDataRoaming pmcnpm.ps1,因为在此系统上禁止运行脚本。有关详细信息 。。。
在win10 系统中搜索框 输入 Windos PowerShell
选择 管理员身份运行
打开了powershell命令行之后,输入
set-ExecutionPolicy RemoteSigned
更改权限为A
输入get-ExecutionPolicy
如下:
3.输入命令
cnpm install node-sass --save
4.运行
npm run dev
亲测成功!
参考来源:
1.https://blog.csdn.net/weixin_29491885/article/details/102454722
2.https://www.cnblogs.com/500m/p/11634969.html
以上是关于Module build failed: Error: Cannot find module 'node-sass’解决的主要内容,如果未能解决你的问题,请参考以下文章
VUE 打包 Module build failed: Error: No PostCSS Config found in
VUE报错:Module build failed: Error: Cannot find module ‘node-sass‘
VUE报错:Module build failed: Error: Cannot find module ‘node-sass‘
Module build failed: Error: Cannot find module ‘node-sass‘ Require stack报错解决
Module build failed: Error: Cannot find module 'node-sass’解决
2021-01-21 Module build failed (from ./node_modules/css-loader/dist/cjs.js)