error with webpack - You may need an appropriate loader to handle this file type











up vote
0
down vote

favorite












I am learning react and trying to create a boilerplate with webpack. I followed a tutorial by traversy everything in his video works but on my computer, I get the error message that an appropriate loader is needed to handle a particular file type.



const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.export = {
entry: './src/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'index_bundle.js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
}


And this is the file where the error is coming from



import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';

ReactDOM.render(<App />, document.getElementById('app'));


Here is the error message:




ERROR in ./src/index.js 5:16 Module parse failed: Unexpected token
(5:16) You may need an appropriate loader to handle this file type. |
import App from './components/App'; |




ReactDOM.render(, document.getElementById('app')); @ multi (webpack)-dev-server/client?http://localhost:8080
(webpack)/hot/dev-server.js ./src main[2]












share|improve this question


















  • 5




    Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
    – Tholle
    Nov 8 at 23:37










  • Just use create-react-app
    – Chris G
    Nov 8 at 23:39










  • JSX is not part of Javascript or HTML.
    – connexo
    Nov 8 at 23:43















up vote
0
down vote

favorite












I am learning react and trying to create a boilerplate with webpack. I followed a tutorial by traversy everything in his video works but on my computer, I get the error message that an appropriate loader is needed to handle a particular file type.



const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.export = {
entry: './src/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'index_bundle.js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
}


And this is the file where the error is coming from



import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';

ReactDOM.render(<App />, document.getElementById('app'));


Here is the error message:




ERROR in ./src/index.js 5:16 Module parse failed: Unexpected token
(5:16) You may need an appropriate loader to handle this file type. |
import App from './components/App'; |




ReactDOM.render(, document.getElementById('app')); @ multi (webpack)-dev-server/client?http://localhost:8080
(webpack)/hot/dev-server.js ./src main[2]












share|improve this question


















  • 5




    Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
    – Tholle
    Nov 8 at 23:37










  • Just use create-react-app
    – Chris G
    Nov 8 at 23:39










  • JSX is not part of Javascript or HTML.
    – connexo
    Nov 8 at 23:43













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am learning react and trying to create a boilerplate with webpack. I followed a tutorial by traversy everything in his video works but on my computer, I get the error message that an appropriate loader is needed to handle a particular file type.



const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.export = {
entry: './src/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'index_bundle.js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
}


And this is the file where the error is coming from



import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';

ReactDOM.render(<App />, document.getElementById('app'));


Here is the error message:




ERROR in ./src/index.js 5:16 Module parse failed: Unexpected token
(5:16) You may need an appropriate loader to handle this file type. |
import App from './components/App'; |




ReactDOM.render(, document.getElementById('app')); @ multi (webpack)-dev-server/client?http://localhost:8080
(webpack)/hot/dev-server.js ./src main[2]












share|improve this question













I am learning react and trying to create a boilerplate with webpack. I followed a tutorial by traversy everything in his video works but on my computer, I get the error message that an appropriate loader is needed to handle a particular file type.



const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.export = {
entry: './src/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'index_bundle.js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
}


And this is the file where the error is coming from



import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';

ReactDOM.render(<App />, document.getElementById('app'));


Here is the error message:




ERROR in ./src/index.js 5:16 Module parse failed: Unexpected token
(5:16) You may need an appropriate loader to handle this file type. |
import App from './components/App'; |




ReactDOM.render(, document.getElementById('app')); @ multi (webpack)-dev-server/client?http://localhost:8080
(webpack)/hot/dev-server.js ./src main[2]









javascript reactjs webpack






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 23:32









David Essien

74312




74312








  • 5




    Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
    – Tholle
    Nov 8 at 23:37










  • Just use create-react-app
    – Chris G
    Nov 8 at 23:39










  • JSX is not part of Javascript or HTML.
    – connexo
    Nov 8 at 23:43














  • 5




    Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
    – Tholle
    Nov 8 at 23:37










  • Just use create-react-app
    – Chris G
    Nov 8 at 23:39










  • JSX is not part of Javascript or HTML.
    – connexo
    Nov 8 at 23:43








5




5




Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
– Tholle
Nov 8 at 23:37




Babel doesn't understand JSX (<App />) out of the box, so you need the React preset.
– Tholle
Nov 8 at 23:37












Just use create-react-app
– Chris G
Nov 8 at 23:39




Just use create-react-app
– Chris G
Nov 8 at 23:39












JSX is not part of Javascript or HTML.
– connexo
Nov 8 at 23:43




JSX is not part of Javascript or HTML.
– connexo
Nov 8 at 23:43












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Before you're able to use JSX syntax, you need to have a list of presets in a .babelrc file, in the root folder of your application.



Here's an example



{ 
"presets": [
"flow",
"es2015",
"react"
]
}


In this example babel would account for a JSX React app, with ES2015 references and flow static typing syntax.



Take a look at this link for more information.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217718%2ferror-with-webpack-you-may-need-an-appropriate-loader-to-handle-this-file-type%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Before you're able to use JSX syntax, you need to have a list of presets in a .babelrc file, in the root folder of your application.



    Here's an example



    { 
    "presets": [
    "flow",
    "es2015",
    "react"
    ]
    }


    In this example babel would account for a JSX React app, with ES2015 references and flow static typing syntax.



    Take a look at this link for more information.






    share|improve this answer

























      up vote
      0
      down vote













      Before you're able to use JSX syntax, you need to have a list of presets in a .babelrc file, in the root folder of your application.



      Here's an example



      { 
      "presets": [
      "flow",
      "es2015",
      "react"
      ]
      }


      In this example babel would account for a JSX React app, with ES2015 references and flow static typing syntax.



      Take a look at this link for more information.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Before you're able to use JSX syntax, you need to have a list of presets in a .babelrc file, in the root folder of your application.



        Here's an example



        { 
        "presets": [
        "flow",
        "es2015",
        "react"
        ]
        }


        In this example babel would account for a JSX React app, with ES2015 references and flow static typing syntax.



        Take a look at this link for more information.






        share|improve this answer












        Before you're able to use JSX syntax, you need to have a list of presets in a .babelrc file, in the root folder of your application.



        Here's an example



        { 
        "presets": [
        "flow",
        "es2015",
        "react"
        ]
        }


        In this example babel would account for a JSX React app, with ES2015 references and flow static typing syntax.



        Take a look at this link for more information.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 at 12:59









        zavjs

        1617




        1617






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217718%2ferror-with-webpack-you-may-need-an-appropriate-loader-to-handle-this-file-type%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff