Digital Consultant
Digital Consultant

Reputation: 11

babel throwing loose configuration error with node.js version 20x

We have old project running on node.js version 12x and now planning to migrate to node.js v20x. After upgrade to node.js v20x while running npm start babel throwing error

'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, @babel/plugin-transform-private-methods and @babel/plugin-transform-private-property-in-object (when they are enabled).

If you already set the same 'loose' mode for these plugins in your config, it's possible that they are enabled multiple times with different options.`
You can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded configuration:

Actually the loose mode was already added in babel.config.js file but still getting error.

Here is the complete babel config code

module.exports = { 
  "presets": [ "@babel/preset-env" ], 
  plugins: [ 
    ["@babel/plugin-proposal-decorators", { "legacy": true }], 
    ["@babel/plugin-proposal-class-properties", { "loose": true }], 
    ["@babel/plugin-proposal-private-methods", { "loose": true }], 
    ["@babel/plugin-proposal-private-property-in-object", { "loose": true }], 
    ["@babel/plugin-transform-class-properties",{ "loose": true }],
    ["@babel/plugin-transform-private-methods",{ "loose": true }], 
    ["@babel/plugin-transform-private-property-in-object",{ "loose": true }],
    ["@babel/plugin-transform-block-scoping"] 
  ] 
}; 

here by adding babel versions that I am using on package.json with node.js version 20.11.1 and npm version 10.5.2 ( which is giving error)

  "devDependencies": { "@babel/core": "^7.13.15", "@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/plugin-proposal-decorators": "^7.4.4", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/plugin-syntax-decorators": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-block-scoping": "^7.2.0", "@babel/plugin-transform-runtime": "7.2.0", "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.13.15", "@babel/preset-react": "^7.0.0", "@babel/register": "^7.0.0" },

Here is my eariler package.json reference with node.js version v12.19.0 and npm version 6.14.8 ( which is working fine)

  "devDependencies": { "@babel/core": "^7.2.2", "@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/plugin-proposal-decorators": "^7.4.4", "@babel/plugin-syntax-decorators": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-block-scoping": "^7.2.0", "@babel/plugin-transform-runtime": "7.2.0", "@babel/polyfill": "^7.4.4", "@babel/preset-env": "^7.4.5", "@babel/preset-react": "^7.0.0", "@babel/register": "^7.0.0" },

Kindly help me

Upvotes: 0

Views: 423

Answers (0)

Related Questions