简体   繁体   English

您可能需要适当的加载程序来处理此文件类型

[英]React You may need an appropriate loader to handle this file type

I'm working on an existing project - when I command npm start the error is - 我正在处理一个现有项目-当我命令npm start ,错误是-

Module parse failed: React/node_modules/react-switch-button/src/react-switch-button.jsx Unexpected token (31:8)
You may need an appropriate loader to handle this file type.

this is my webpack.config.js : 这是我的webpack.config.js:

        module.exports = {
      entry: [
        './src/index.js'
      ],
      output: {
        path: __dirname,
        publicPath: '/',
        filename: 'bundle.js'
      },
      module: {
        loaders: [{
          exclude: /node_modules/, //before I added "include" the loading errer 
//was about react-switch-button.jsx but compiled  index.js
          include: __dirname + /app/,// after adding this, can't build index.js (previus error fixed)
          loader: 'babel-loader',
          query: {
            presets: ['react', 'es2015', 'stage-1']
          }
        }]
      },
      resolve: {
        extensions: ['.js', '.jsx']
      },
      devServer: {
        historyApiFallback: true,
        contentBase: './'
      }
    };

I've solved it by adding include: __dirname + /app/, but then I got the same error but now its about the ./src/index.js file I simply want to launch it on chrome 我已经通过添加包括来解决了这个问题: __dirname + /app/,但是我遇到了同样的错误,但是现在它关于./src/index.js文件,我只是想在chrome上启动它

Remove exclude: /node_modules/ from the loader config. 从加载程序配置中删除exclude: /node_modules/

Looks like a package you are using isn't compiled down to es5, so you need to tell Webpack to use babel on that file as well. 看起来您正在使用的软件包尚未编译到es5,因此您需要告诉Webpack在该文件上也使用babel。 Ideally you should only allow babel to build that one package. 理想情况下,您只应允许babel构建该软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django / React-您可能需要适当的加载程序来处理此文件类型 - Django/React - You may need an appropriate loader to handle this file type 意外字符'@'您可能需要适当的加载程序来处理此文件类型 - Unexpected character '@' You may need an appropriate loader to handle this file type ReactJS 错误您可能需要适当的加载程序来处理此文件类型 - ReactJS error You may need an appropriate loader to handle this file type CSS - 您可能需要适当的加载程序来处理此文件类型 - CSS - You may need an appropriate loader to handle this file type 您可能需要适当的加载程序来处理此文件类型错误 - You may need an appropriate loader to handle this file type-error Webpack:您可能需要适当的加载器来处理此文件类型 - Webpack: You may need an appropriate loader to handle this file type webpack错误-您可能需要适当的加载程序来处理此文件类型 - error with webpack - You may need an appropriate loader to handle this file type 你可能需要一个合适的加载器来处理这种文件类型的 js - You may need an appropriate loader to handle this file type js glsify - 错误'您可能需要适当的加载程序来处理此文件类型'? - glsify - error 'You may need an appropriate loader to handle this file type'? Webpack 和 Babel “你可能需要一个合适的加载器来处理这种文件类型” - "You may need an appropriate loader to handle this file type" with Webpack and Babel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM