question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Duplicate plugin/preset detected.

See original GitHub issue

Bug Report

Current Behavior

ERROR in ./js/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Duplicate plugin/preset detected. If you’d like to use two separate instances of a plugin,
they need separate names, e.g.

plugins: [
[‘some-plugin’, {}],
[‘some-plugin’, {}, ‘some unique name’],
]

My webpack.prod.js

var HtmlWebpackPlugin = require('html-webpack-plugin');

var config = {
	
	mode: 'production',
	target: 'electron-main',
	entry: './js/index.js',

	output: {
		path: __dirname + '/interface_build/prod',
		publicPath: './',
		filename: 'app.js'
	},

	module: {
		rules: [
			{
				test: /\.js$/,
				loader: 'babel-loader',
				options: {
					babelrc: true,
					presets: ['@babel/preset-env', '@babel/preset-react'],
				},
				exclude: /node_modules/,
				include: __dirname
			},
			{
				test: /\.scss$/,
				use: [
					'style-loader',
					'css-loader',
					'sass-loader'
				],
				include: __dirname
			},
			{
				test: /\.css$/,
				use: [
					'style-loader',
					'css-loader'
				],
				include: __dirname
			},
			{
				test: /\.(jpe?g|png|gif|svg)$/i,
				use: [
					{
						loader: 'url-loader',
						options: { limit: 10000 }
					},
					{
						loader: 'img-loader',
						options: { progressive: true }
					}
				],
				// loader: 'url-loader?limit=10000!img?progressive=true',
				include: __dirname
			},
			{
				test: /\.(woff|woff2|eot|ttf|otf)$/i,
				loader: 'file-loader',
				include: __dirname
			}
		]
	},
	plugins: [
		new HtmlWebpackPlugin({
			template: 'index.template.ejs',
			filename: 'index.html',
		}),
		new HtmlWebpackPlugin({
			template: 'splash.template.ejs',
			filename: 'splash.html',
			inject: false
		}),
		new HtmlWebpackPlugin({
			template: 'cpu.template.ejs',
			filename: 'cpu.html',
			inject: false
		})]
};


module.exports = config;

My My webpack.dev.js

var HtmlWebpackPlugin = require('html-webpack-plugin');

var config = {
	watch: true,
	mode: 'development',
	target: 'electron-main',
	entry: './js/index.js',
	devServer: {
		historyApiFallback: true,
		compress: true,
		hot: true
	},

	output: {
		path: __dirname + '/interface_build/dev',
		publicPath: './',
		filename: 'app.js'
	},

	module: {
		rules: [
			{
				test: /\.js$/,
				loader: 'babel-loader',
				options: {
				  babelrc: false,
				  presets: ['@babel/preset-env', '@babel/preset-react'],
				},
				exclude: /node_modules/,
				include: __dirname
			},
			{
				test: /\.scss$/,
				use: [
					'style-loader',
					'css-loader',
					'sass-loader'
				],
				include: __dirname
			},
			{
				test: /\.css$/,
				use: [
					'style-loader',
					'css-loader'
				],
				include: __dirname
			},
			{
				test: /\.(jpe?g|png|gif|svg)$/i,
				use: [
					{
						loader: 'url-loader',
						options: { limit: 10000 }
					},
					{
						loader: 'img-loader',
						options: { progressive: true }
					}
				],
				// loader: 'url-loader?limit=10000!img?progressive=true',
				include: __dirname
			},
			{
				test: /\.(woff|woff2|eot|ttf|otf)$/i,
				loader: 'file-loader',
				include: __dirname
			}
		]
	},
	plugins: [
		new HtmlWebpackPlugin({
			template: 'index.template.ejs',
			filename: 'index.html',
		}),
		new HtmlWebpackPlugin({
			template: 'splash.template.ejs',
			filename: 'splash.html',
			inject: false
		}),
		new HtmlWebpackPlugin({
			template: 'cpu.template.ejs',
			filename: 'cpu.html',
			inject: false
		})
	]
};


module.exports = config;

Expected behavior/code A clear and concise description of what you expected to happen (or code).

Babel Configuration (.babelrc, package.json, cli command)

{
	"passPerPreset": true,
	"presets": [
		"@babel/preset-env",
		"@babel/preset-react"
	],
	"env": {
		"development": {
			"presets": [
				"react-optimize"
			],
		},
		"production": {
			
			"plugins": [
				"transform-react-constant-elements",
				"transform-react-inline-elements",
				"transform-react-remove-prop-types",
				"transform-react-pure-class-to-function"
			]
		},
		"test": {
			"plugins": [
				"istanbul"
			]
		}
	},
	"plugins": [
		"transform-class-properties",
		"transform-object-rest-spread"
	]
}

Environment

  • Babel version(s): v6.23.0
  • Node/npm version: Node v11.13.0 / npm v6.9.0
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: loader

Possible Solution

Additional context/Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
burakkpcommented, Apr 11, 2019

Ok, so it’s working now?

Yes man, Thank you.

1reaction
nicolo-ribaudocommented, Apr 9, 2019

You have the env and react presets both in the webpack config and in .babelrc: when the configs are merged, the presets are duplicated.

Also, you are mixing Babel 6 and Babel 7 packages: it will probably cause problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Babel 7 fails with single plugin saying "Duplicate ...
This is a babel error basically saying that you have defined your plugin @babel/plugin-transform-regenerator twice - more or less indirectly ...
Read more >
Babel error Duplicate plugin/preset detected (Trying to run ...
I found some information where it says: most likely cause of the error mentioned is that you have one or more default plugins...
Read more >
Module build failed: Error: Duplicate plugin/preset detected ...
[Solved]-Module build failed: Error: Duplicate plugin/preset detected-Vue.js ... Update your package.json to the following, run npm install, then run your command ...
Read more >
Error:Duplicate plugin/preset detected
Error :Duplicate plugin/preset detected · module.exports = { · "presets": [ · "@vue/cli-plugin-babel/preset" · ], · "plugins": [ · [ · "component", ·...
Read more >
解决:Error: Duplicate plugin/preset detected. If you'd like to ...
解决:Error: Duplicate plugin/preset detected. If you'd like to use two separate i ... 版权声明:本文为CSDN博主「yu472623295」的原创文章,遵循CC 4.0 BY-SA版权协议 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found