webpack报错需要合适的loader

以前做vue项目都好好的,最近做react,公共配置感觉加个jsx就可以了吧,然而不是这样的。

一、问题描述

You may need an appropriate loader to handle this file type。

二、问题分析

babelrc我配置了,babel-loader也配置正确,问题出现在include值上面,还原现场。

module: {
        rules: [{
            test: /\.(js|jsx)$/,
            exclude: /node_modules/,
            loader: ‘babel-loader‘,
            include: [resolve(‘src‘), resolve(‘test‘)]
        }]
}

三、解决方案

去掉最后一行配置即可,像这样写。

module: {
        rules: [{
            test: /\.(js|jsx)$/,
            exclude: /node_modules/,
            loader: ‘babel-loader‘
        }]
}

四、疑惑

但是之前做vue项目的时候,我加include配置就不会报错呢,react项目咋就不行了呢?匪夷所思,后续补充。。。

原文地址:https://www.cnblogs.com/camille666/p/webpack_loader_config_error.html

时间: 2024-08-11 19:49:51

webpack报错需要合适的loader的相关文章

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报错:Cannot assign to read only property 'exports' of object '#<Object>'

这个倒霉错误在mac电脑上开发的时候非常顺利,可是用windows的时候就会报错. 百度查不到,google一查果然有. 原因是:The code above is ok. You can mix require and export. You can't mix import and module.exports. 也就是说,在webpack打包的时候,可以在js文件中混用require和export.但是不能混用import 以及module.exports. 于是查了一下代码,在自己的ma

webpack报错no postcss config...

终端里运行的错误: 查了好多资料,最后找到解决办法,改为: const webpack = require('webpack'); // const autoprefixer = require('autoprefixer'); // const values = require('postcss-modules-values'); module.exports = { devtool: 'eval-source-map', entry: __dirname + "/app/main.js&qu

Plugin/Preset files are not allowed to export objects,webpack报错/babel报错的解决方法

1.为什么会报错 ? 这里抱着错误是因为 babel 的版本冲突. 多是因为你的 babel 依赖包不兼容. 可以查看你的 package.json 的依赖列表 即有 babel 7.0 版本的( @babel/core , @babel/preset-react ) 也可命令查看 bebel-cli 的版本 ( babel -V ) 也有 babel 6.0 版本的 ( [email protected] , [email protected] , [email protected] ) 如果

webpack 报错 path is not defind

webpack.config.js里的内容是这样的,注意标红的地方: 首先,绝对路径'./dist'是 没有问题的 那么,查了很多,最后看到别人的webpack.config.js里面这样写着,现在const里面声明在用: 最后成功运行.

Tomcat多应用启动报错:org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [].

Loaded org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller$RunnableRemove from file:/mnt/software/apache-tomcat-9.0.0.M22/lib/tomcat-coyote.jar] [Loaded org.apache.catalina.core.AccessLogAdapter from file:/mnt/software/apache-tomcat-9.0.0.M22/

webpack报错解决

1. Error: Cannot find module '@babel/core' 原因:版本搭配问题 解决退回版本 npm install [email protected]7.1.5 原文地址:https://www.cnblogs.com/cycczh/p/11560014.html

配置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命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法

我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are recommended choices, delivered as separate packages: - webpack-cli (https://github.com/webpack/webpack-cli) The original webpack full-featured CLI. We wi