I need help diagnosing and fixing this error:
"Error: only one instance of babel-polyfill is allowed"
I have the following in my package.json:
"devDependencies": {
"babel-core": "^6.23.1",
"babel-jest": "^19.0.0",
"babel-loader": "^6.3.2",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0" ...
"dependencies": {
"babel-polyfill": "^6.23.0" ...
And this and this entry line in my webpack config:
entry: ["babel-polyfill", path.resolve(APP_PATH, 'index')],
...
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
// specify that we will be dealing with React code
presets: ['react', 'es2015']
}
}
]}
If the culprit is HtmlWebpackPlugin, you need to add the option inject: false
when instancing the plugin. Certain configurations without this option causes your built javascript code to be loaded twice.