码迷,mamicode.com
首页 > 其他好文 > 详细

Module build failed: Error: Cannot find module 'node-sass’解决

时间:2020-02-08 00:11:41      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:try   index   exe   serve   ace   依赖   lis   node   resolve   


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:\Workspace\vscode\user_h5\node_modules\sass-loader\lib\loader.js
- F:\Workspace\vscode\user_h5\node_modules\loader-runner\lib\loadLoader.js
- F:\Workspace\vscode\user_h5\node_modules\loader-runner\lib\LoaderRunner.js
- F:\Workspace\vscode\user_h5\node_modules\webpack\lib\NormalModule.js
- F:\Workspace\vscode\user_h5\node_modules\webpack\lib\NormalModuleFactory.js
- F:\Workspace\vscode\user_h5\node_modules\webpack\lib\Compiler.js
- F:\Workspace\vscode\user_h5\node_modules\webpack\lib\webpack.js
- F:\Workspace\vscode\user_h5\node_modules\webpack-dev-server\lib\Server.js
- F:\Workspace\vscode\user_h5\node_modules\webpack-dev-server\bin\webpack-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:\Workspace\vscode\user_h5\node_modules\sass-loader\lib\loader.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:\Users\93457\AppData\Roaming\npm\cnpm.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’解决

标签:try   index   exe   serve   ace   依赖   lis   node   resolve   

原文地址:https://www.cnblogs.com/mfbzr/p/12274950.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!