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]
javascript reactjs webpack
add a comment |
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]
javascript reactjs webpack
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
add a comment |
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]
javascript reactjs webpack
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
javascript reactjs webpack
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 14 at 12:59
zavjs
1617
1617
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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