webpack solution
If you got this error while working in React with webpack and HMR.
You need to create template index.html
and save it in src
folder:
<html>
<body>
<div id="root"></root>
</body>
</html>
Now when we have template with id="root"
we need to tell webpack to generate index.html which will mirror our index.html
file.
To do that:
plugins: [
new HtmlWebpackPlugin({
title: "Application name",
template: './src/index.html'
})
],
template
property will tell webpack how to build index.html
file.