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 的坑的更多相关文章

  1. 初学Vue 遇到Module not found:Error:Can`t resolve 'less-loader' 问题

    学习vue时,导入一个子组件时遇到Module not found:Error:Can`t resolve 'less-loader' 问题,实际上时在子组件中的样式里加了这么个代码 <styl ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. vue报错——Module not found: Error: Can't resolve 'less-loader sass' in ...

    npm install sass-loader -D npm install node-sass -D

  8. Module not found: Error: Can't resolve ' vue-resource'

    问题: 在学习vue的过程中出现了这个问题,说明VueResource模块没有安装. 解决方法: 打开终端,进入当前项目所在目录,输入指令 npm install vue-resource --sav ...

  9. vue项目出现Module not found: Error: Can't resolve 'stylus-loader'错误解决方案

    因为没有安装stylus和stylus-loader npm install stylus stylus-loader --save-dev 安装成功后,使用npm install重新建立依赖 打开项 ...

随机推荐

  1. DataFrame索引和切片

    import numpy as np import pandas as pd from pandas import DataFrame, Seriesdf = DataFrame(data=np.ra ...

  2. Python3-Django-1.开发环境搭建

    官网 https://www.djangoproject.com/ 安装 http://www.runoob.com/django/django-install.html 创建项目 方式一(命令行): ...

  3. ajax前后端交互原理(1)

    1.Node.js简介 1.1.前后台数据交互流程 在web开发中,我们经常听说前端和后台,他们分别是做什么具体工作的呢?他们怎样交互的呢?我们得把这些基础的问题都搞明白了,才有一个大致的学习方向,首 ...

  4. C#操作SharePoint文档库文档

    using (Stream file = spFile.OpenBinaryStream()) { //其余代码 }

  5. H5调用手机的相机/摄像/录音等功能 _input:file的capture属性说明

    H5使用input标签调用系统默许相机,摄像,录音功能.使用input:file标签, 去调用系统默认相机,摄像,录音功能,其实是有个capture属性,直接说明需要调用什么功能: <input ...

  6. CSS3的过渡效果,使用transition实现鼠标移入/移出效果

    在css中使用伪类虽然实现了样式的改变,但由于没有过渡效果会显得很生硬.以前如果要实现过渡,就需要借助第三方的js框架来实现.现在只需要使用CSS3的过渡(transition)功能,就可以从一组样式 ...

  7. 使用flex实现5种常用布局

    Sticky Footer 经典的上-中-下布局. 当页面内容高度小于可视区域高度时,footer 吸附在底部:当页面内容高度大于可视区域高度时,footer 被撑开排在 content 下方 dem ...

  8. 冷知识:达夫设备(Duff's Device)效率真的很高吗?

    ID:技术让梦想更伟大 作者:李肖遥 wechat链接:https://mp.weixin.qq.com/s/b1jQDH22hk9lhdC9nDqI6w 相信大家写业务逻辑的时候,都是面向if.el ...

  9. 安装nodejs,npm,yarn

    先安装nodejs和npm sudo apt update sudo apt install nodejs npm #验证一下 nodejs --version npm --version 如果nod ...

  10. Centos7 python 安装 Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

    安装python时出现Ignoring ensurepip failure:pip required SSL/TLS 因为没有安装OpenSSL 使用yum install openssl-devel