DEV Community

Setup React, Babel 7, and Webpack 4

Hunter Johnson on April 04, 2019

Create react app makes it extremely easy to get up and running with React providing sensible defaults. However, you're going to reach a point where...
Collapse
 
stackoverflowsam93 profile image
stackoverflowsam93

I don't know if it's because I was using npm but I was receiving the error

Uncaught Error: Target container is not a DOM element.

Once I removed the lines

"plugins: [
new HtmlWebpackPlugin({
inject: false,
template: HtmlWebpackTemplate,
appMountId: 'app',
}),
],"

from my webpack.config.js file this solution worked pefectly

Easiest solution on the internet in 2019.
Although the line "yarn add react react-dom" could be a little bit more visible

Collapse
 
0xhjohnson profile image
Hunter Johnson

Html Webpack plugin injects a index.html file for you with a div element containing an ID of “app”. Did you happen to be using a separate index.html file?