Module not found: Error: Can't resolve './style':配置 extensions 的坑
ERROR in ./src/index.js
Module not found: Error: Can't resolve './style' in 'D:\gitcode\github\learn-webpack\demo15\src'
@ ./src/index.js 8:0-17
网上的解决方案
1.确认是否安装 css-loader 和 style-loader
npm install css-loader style-loader -D
2.配置 module.rules
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
}
我的问题及解决方案
我的错误其实是 在配置 resolve.extensions 时发生错误,我配置成了
extensions: ['js', 'css', 'json'] ×
正确的配置方法是:
// webpack.config.js
module.exports = {
resolve: {
extensions: ['.js', '.css', '.json']
}
}
总结:
- resolve.extensions 扩展名要求写全,不支持不加
.的写法。 - 报错提示找不到
./style模块,其实就是因为补全扩展名的配置没有生效。
Module not found: Error: Can't resolve './style':配置 extensions 的坑的更多相关文章
- 初学Vue 遇到Module not found:Error:Can`t resolve 'less-loader' 问题
学习vue时,导入一个子组件时遇到Module not found:Error:Can`t resolve 'less-loader' 问题,实际上时在子组件中的样式里加了这么个代码 <styl ...
- Module not found: Error: Can't resolve 'XXX' in 'XXXX'
故障 控制台运行webpack/npm时出现 Module not found: Error: Can't resolve 'XXX' in 'XXXX' 解决方案 npm i XXX --save ...
- angular2 ng build --prod 报错:Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
调试页面 ng serve 正常 ng build 也正常 ng build --prod 异常:Module not found: Error: Can't resolve './$$_gendir ...
- Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src'
ERROR in Entry module not found: Error: Can't resolve './src' in 'E:\ASUS\Documents\VSCode files\Web ...
- Module not found: Error: Can't resolve '@babel/runtime/helpers/classCallCheck' and Module not found: Error: Can't resolve '@babel/runtime/helpers/defineProperty'
These two mistakes are really just one mistake, This is because the following file @babel/runtime ca ...
- Module not found: Error: Can't resolve "xxx" in "xxx"
报错信息 ERROR in multi ./src/index.js ./dist/bundle.js Module not found: Error: Can't resolve './dist/b ...
- vue报错——Module not found: Error: Can't resolve 'less-loader sass' in ...
npm install sass-loader -D npm install node-sass -D
- Module not found: Error: Can't resolve ' vue-resource'
问题: 在学习vue的过程中出现了这个问题,说明VueResource模块没有安装. 解决方法: 打开终端,进入当前项目所在目录,输入指令 npm install vue-resource --sav ...
- vue项目出现Module not found: Error: Can't resolve 'stylus-loader'错误解决方案
因为没有安装stylus和stylus-loader npm install stylus stylus-loader --save-dev 安装成功后,使用npm install重新建立依赖 打开项 ...
随机推荐
- 【面试篇】寒冬求职之你必须要懂的Web安全
https://segmentfault.com/a/1190000019158228 随着互联网的发展,各种Web应用变得越来越复杂,满足了用户的各种需求的同时,各种网络安全问题也接踵而至.作为前端 ...
- android屏幕适配的全攻略3-动态获取手机屏幕宽高及动态设置控件宽高
1.获取手机屏幕宽高: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetr ...
- redis基础一
2.修改redis.conf的配置文件有两个地方 a.将daemonize设置成true支持后台启动 b.将redis的数据库文件保存到 下面的目录 3.启动redis服务器 4.操作redis ,给 ...
- 僵尸扫描-scapy、nmap
如果不知道僵尸扫描是什么,请参考我的这篇博客 实验环境: kali(攻击者) 192.168.0.103 metasploitable2(目标主机) 192.168.0.104 win xp sp2( ...
- keras训练函数fit和fit_generator对比,图像生成器ImageDataGenerator数据增强
1. [深度学习] Keras 如何使用fit和fit_generator https://blog.csdn.net/zwqjoy/article/details/88356094 ps:解决样本数 ...
- mybatis源码配置文件解析之五:解析mappers标签
在上篇博客中分析了plugins标签,<mybatis源码配置文件解析之四:解析plugins标签>,了解了其使用方式及背后的原理.现在来分析<mappers>标签. 一.概述 ...
- postman不能启动的问题解决
1.postman启动不了,启动时提示“postman resolving transporter buffer”,不能正常启动 第一步,删除:在chrome-更多工具-扩展程序里面删除了postma ...
- 吐血推荐,想进BAT必看
不必太纠结于当下,也不必太忧虑未来,人生没有无用的经历,当你经历过一些事情后,眼前的风景已经和从前不一样了.--村上春树 一.包含如下内容 ActiveMQ消息中间件面试专题 BAT80道面试题 BA ...
- 编译运行Zookeeper源码
GitHub地址: https://github.com/apache/zookeeper 最新版本的 zookeeper 已经使用了 maven 进行管理了.不再需要安装 Ant 下载完成之后.使用 ...
- Oracle查询表空间使用率很慢
Oracle查询表空间使用率很慢 问题描述 执行查询表空间的语句,需要接近2min的时间才能执行完成. 以前也在其他客户的生产库遇到过一样的情况,当时是由于回收站的内容过多引起的. 不过这次的情况却不 ...