question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

You may need an appropriate loader to handle this file type with react@15.4.2, webpack@2.2.1 and babel-loader@6.2.10

See original GitHub issue

Webpack Version: 2.2.1

Babel Core Version: 6.22.1

Babel Loader Version: 6.2.10

Please tell us about your environment: Linux

Current behavior: it gives an error You may need an appropriate loader to handle this file type with

Expected/desired behavior: no error

  //package.json
  "babel-core": "^6.22.1",
  "babel-loader": "^6.2.10",
  "babel-preset-es2015": "^6.22.0",
  "babel-preset-react": "^6.22.0",
  "css-loader": "^0.26.1",
  "extract-text-webpack-plugin": "^2.0.0-rc.2",
  "html-webpack-plugin": "^2.28.0",
  "node-sass": "^4.5.0",
  "react": "^15.4.2",
  "react-dom": "^15.4.2",
  "sass-loader": "^4.1.1",
  "style-loader": "^0.13.1",
  "uglifyjs-webpack-plugin": "^0.1.2",
  "webpack": "^2.2.1"
//webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin'),
      UglifyJSPlugin = require('uglifyjs-webpack-plugin'),
      ExtractTextPlugin = require("extract-text-webpack-plugin"),
      path = require("path");

module.exports = {
  "entry": ["./app/index.js"],
  "output": {
    "path": "output",
    "filename": "[name]-[chunkhash].js",
    "libraryTarget": "umd"
  },
  "module": {
    rules: [
      {
        "exclude": "/node_modules/",
        "include": "./app/",
        "loader": "babel-loader",
        "options": {
          "presets": ["es2015", "react"]
        },
        "test": /\.jsx?$/
      },
      {
        "exclude": "/node_modules/",
        "use": ExtractTextPlugin.extract({
          "fallbackLoader": "style-loader",
          "loader": ["css-loader", "sass-loader"]
        }),
        "test": /\.scss$/
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin(),
    new ExtractTextPlugin("[name]-[contenthash].css")
  ]
}
//./app/index.js
let React = require("react"),
    ReactDom = require("react-dom");

ReactDom.render(
  <div id="root"></div>,
  document.getElementsByTagName("body")
);

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:37 (4 by maintainers)

github_iconTop GitHub Comments

44reactions
loganfsmythcommented, Feb 2, 2017

If I had to guess, you want

        "exclude": "/node_modules/",
        "include": "./app/",

to be

        "include": __dirname + "/app/",

or

        "exclude": /node_modules/,

paths have to be absolute paths, or regexes.

27reactions
Coutocommented, Jun 22, 2017

@Bijayini Your test values are a string value, which means they won’t match during the test resolution. You can switch to:

  {test: /\.js$/ , loader:'babel-loader', exclude: '/node_modules/'},
  {test: /\.jsx$/ , loader:'babel-loader', exclude: '/node_modules/'}
Read more comments on GitHub >

github_iconTop Results From Across the Web

"You may need an appropriate loader to handle this file type ...
js file is doing is importing react, but it seems like the 'babel-loader' is not working. I am using 'babel-loader' 6.0.0. javascript ·...
Read more >
You may need an appropriate loader to handle this file type ...
I 'm having a problem configuring Webpack for Typescript and React. After running the NPM script: webpack serves ./webpack/webpack.config.ts ...
Read more >
"You may need an appropriate loader to handle this file type ...
[Solved]-Webpack error: "You may need an appropriate loader to handle this file type"-Reactjs. Search. score:2. { test : /\.(js|jsx)$/, include : APP_DIR, ...
Read more >
Fast Inline Images With React and Webpack - Request Metrics
Webpack is great for building React applications, but did you know it can help you ... (1:0) You may need an appropriate loader...
Read more >
Using Webpack with React, Pt. 1 - Toptal
There are other types of resources that we might need in a React application, which we will cover in the following sections. CSS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found