I know this is a fairly common error and is a result of poor configuration in config file. I've searched few posts but can't seem find the right solution. I'm fairly certain this was caused after installing two specific dependencies: babel-preset-es2015 && babel-preset-react.
I've tried uninstalling / re-installing, with no resolve.
I was following this tutorial.
Thank you for any help in advance.
The error code reads:
Version: webpack 2.1.0-beta.22
Time: 55ms
Asset Size Chunks Chunk Names
bundle.js 2.68 kB 0 [emitted] main
[0] ./public/app.js 246 bytes {0} [built] [failed] [1 error]
ERROR in ./public/app.js
Module parse failed: /Users/user/Desktop/Development/CCJournal/public/app.js Unexpected token (5:1)
You may need an appropriate loader to handle this file type.
|
| render(
| <div>
| <h1> Testing </h1>
| </div>,
Webpack.config.js
module.exports = {
entry: "./public/app.js",
output: {
path: __dirname + "/public",
filename: 'bundle.js'
},
module: {
loader: [
{
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
},
watch: true
}
App.js
import React from 'react'
import { render } from 'react-dom'
render(
<div>
<h1> Testing </h1>
</div>,
document.getElementById('app')
)
Package Json
{
"name": "ccjournal",
"version": "1.0.0",
"description": "Test Assignment",
"main": "index.js",
"scripts": {
"webpack": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"express": "^4.14.1",
"pug": "^2.0.0-beta10",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"webpack": "^2.1.0-beta.22"
}
}