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. 06.DBUnit实际运用

    在上面的代码中 package com.fjnu.service; import java.io.FileWriter; import java.sql.SQLException; import st ...

  2. 使用docker创建rabbitMQ容器

    1.拉去镜像 docker pull rabbitmq:3.7.7-management

  3. mybatis源码配置文件解析之五:解析mappers标签(解析XML映射文件)

    在上篇文章中分析了mybatis解析<mappers>标签,<mybatis源码配置文件解析之五:解析mappers标签>重点分析了如何解析<mappers>标签中 ...

  4. Spreading the Wealth

    题目 A Communist regime is trying to redistribute wealth in a village. They have have decided to sit e ...

  5. Bash 脚本编程的一些高级用法

    概述 偶然间发现 man bash 上其实详细讲解了 shell 编程的语法,包括一些很少用却很实用的高级语法.就像发现了宝藏的孩子,兴奋莫名.于是参考man bash,结合自己的理解,整理出了这篇文 ...

  6. Markdown-it-latex2img

    Markdown-it-latex2img LaTex plugin for markdown-it markdown parser,Server side MathJax Renderer. Bac ...

  7. Spring Boot2.x 的Druid连接池配置[附带监控]

    父依赖[Spring Boot 2.1.x版本] <parent> <groupId>org.springframework.boot</groupId> < ...

  8. 关于延迟段创建-P1

    文章目录 1 疑问点 2 环境创建 2.1 创建用户 2.2 创建表test 2.3 查看表的段信息 2.4 延迟段创建相关参数 1 疑问点 P1页有句话说道: 在Oracle 11.2.0.3.0以 ...

  9. Django初级之django简介

    1.Django简介 Django是Python语言中的一个web框架,Python语言中主流的web框架有Django.Tornado.Flask 等多种.Django相较与其它WEB框架,其优势为 ...

  10. 07 Vue常见插件

    项目功能插件 1.vue-router { path: '/', name: 'home', // 路由的重定向 redirect: '/home' } { // 一级路由, 在根组件中被渲染, 替换 ...