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:\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’解决

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

时间: 2024-10-08 18:30:09

Module build failed: Error: Cannot find module 'node-sass’解决的相关文章

vue.js报错:Module build failed: Error: No parser and no file path given, couldn't infer a parser.

ERROR Failed to compile with 2 errors 12:00:33 error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a parser. at normalize (C:\Users\admin\Desktop\222\demo\node_modules\prettier\index.js:7051:13) at form

【Vue报错】Module build failed: Error: No parser and no file path given, couldn't infer a p arser.

在创建一个vue项目启动时报错,报错的内容为: error in ./src/App.vue Module build failed: Error: No parser and no file path given, couldn't infer a p arser. at UndefinedParserError.Wrapper (D:\dyyc\bookstore\[email protected] [email protected]\index.js:1948:14) at new Und

Module build failed: Error: No PostCSS Config found

使用vue框架写pc页面时,我们经常会用到element-ui这个框架. 当我们把需要的东西都装在好运行项目的时候,有时会出现这样的错误: 这是因为缺少了一个配置文件,postcss.config.js,配置内容如下 module.exports = { plugins: { 'autoprefixer': {browsers: 'last 5 version'} } } 注意:这个文件是放在项目的根目录下的 原文地址:https://www.cnblogs.com/caoxueying2018

移动vue项目,启动错误:Module build failed: Error: No PostCSS Config found in:

解决办法:在根目录新建postcss.config.js module.exports = { plugins: { 'autoprefixer': {browsers: 'last 5 version'} } } 然后再次启动项目即可解决 原文地址:https://www.cnblogs.com/johnjackson/p/10783075.html

webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-env' from '...' - Did you mean "@babel/env"?

webpack报错:Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-env' from '...' - Did you mean "@babel/env"? 原因: babel-core和babel-preset-env依赖被替换为@babel/core和@babel/preset-env,因为新版本的Babel7中对

配置webpack loader vue 报错:Module build failed: TypeError: this._init is not a function

单文件组件 引入时报错 配置webpage.config.js中的vue 需要如下写法 { test: /\.vue/, loader: "vue-loader", } 之前写的loader 是vue, 并没有加 -loader所以报错

webpack中Module build failed: Unknown word (2:1)

在新建的webpack.config.js文件中配置好style-loader和css-loader,注意顺序为:style-loader,css-loader,less-loader,postcss-loader.下面为工程目录: 配置好的webpack.config.js文件: 如果以上步骤都没问题了.还是出现该错误,应该考虑缓存的问题,解决办法: 1.使用配置好的npm start在控制台重新打包: 2.然后重新启动服务(命令:npm run server): 关于这两个命令需要配置,具体

blucesun 解决npm报错:Module build failed: TypeError: this.getResolve is not a function

1.sass-loader的版本过高导致的编译错误,当前最高版本是8.x,需要退回到7.3.1 运行: npm uninstall sass-loader(卸载当前版本) npm install sass[email protected]7.3.1 --save-dev 2.如果上面的方法不行,或者又产生其他相关的错误,可以尝试一下在webpack.base.config.js里面添加: 原文地址:https://www.cnblogs.com/jasonLiu2018/p/11996968.h

Error: Cannot find module 'internal/fs'

$ sudo n 6.9.1 $ sudo npm -g install [email protected] $ sudo n stable curl -0 -L https://npmjs.org/install.sh | sudo sh ncu -g or npm outdated -g In linux,when I update to node 7, this happened, "npm cache clean" does work. In windows, npm cach