Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel : duplicate plugin/preset error detected

I am doing a react course on front-end masters,and we had to modify the babel config to allow state instantiations like :state = {index: 0} in class components, however upon running the command:
npm install -D babel-eslint @babel/core @babel/preset-env @babel/plugin-proposal-class-properties @babel/preset-react
,and creating a .babelrc file in root-directory and modifying it as such:
{ "presets": ["@babel/preset-react", "@babel/preset-env"], "plugins": ["@babel/plugin-proposal-class-properties"] }.
I get the following error:

/home/rahat/Documents/react_adopt_me/src/App.js: 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'],
      ]
    
    Duplicates detected are:
    [
      {
        "alias": "/home/rahat/Documents/react_adopt_me/src/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
        "dirname": "/home/rahat/Documents/react_adopt_me/src",
        "ownPass": false,
        "file": {
          "request": "@babel/plugin-proposal-class-properties",
          "resolved": "/home/rahat/Documents/react_adopt_me/src/node_modules/@babel/plugin-proposal-class-properties/lib/index.js"
        }
      },
      {
        "alias": "base$2",
        "options": {
          "loose": "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error"
        },
        "dirname": "/home/rahat/Documents/react_adopt_me/src",
        "ownPass": false
      }
    ]
like image 291
Rahat Avatar asked Oct 15 '25 04:10

Rahat


1 Answers

I believe this may be a node version issue.

If you want a quick fix then uninstall the plugin-proposal-class-properties via:

npm uninstall @babel/plugin-proposal-class-properties

then disable/delete the plugin in .babelrc:

{
    "presets": ["@babel/preset-react", "@babel/preset-env"]
    //"plugins": ["@babel/plugin-proposal-class-properties"]
}

clear the cache:

npm run clear-build-cache

Then run the server again.

like image 78
jcoszig Avatar answered Oct 16 '25 19:10

jcoszig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!