Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Quick handling of the error: plugin/preset files are not allowed to export objects, only functions error
Next
Answered
Richard Gagnon
  • 5
Richard Gagnon
Asked: May 17, 20222022-05-17T13:59:51+00:00 2022-05-17T13:59:51+00:00In: javascript

Quick handling of the error: plugin/preset files are not allowed to export objects, only functions error

  • 5

. Advertisement .

..3..

. Advertisement .

..4..

I get an error:

ERROR in ./index.js
 Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.

when I try to run the following code:

var config = {
  entry: './index.js',
  output: {
  path: __dirname,
  filename: 'block.build.js',
  },
  devServer: {
  contentBase: './Carousel'
  },
  module : {
  rules : [
  {
  test: /.js$/,
  loader: 'babel-loader',
  exclude: /node_modules/,
  query: {
  presets: ['react', 'es2015'],
  plugins: ['transform-class-properties']
  }
  }
  ]
  }
 };
 module.exports = config;
{
  "name": "carousel",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "dependencies": {
    "@babel/core": "^7.0.0-beta.40",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "babel-preset-react": "^6.24.1",
    "cross-env": "^5.1.3",
    "lodash": "^4.17.5",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-swipeable": "^4.2.0",
    "styled-components": "^3.2.1"
  },
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "watch": "webpack --watch",
    "start": "webpack-dev-server --open",
    "build": "webpack"
  },
  "devDependencies": {
    "webpack": "^4.1.1",
    "webpack-cli": "^2.0.10",
    "webpack-dev-server": "^3.1.0"
  },
  "author": "brad traversy",
  "license": "ISC"
}

How to fix the error: plugin/preset files are not allowed to export objects, only functions. Please give me some good ideas.

preset files are not allowed to export objects
  • 2 2 Answers
  • 186 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-06-06T09:35:57+00:00Added an answer on June 6, 2022 at 9:35 am

    The cause:

    It is not possible to guarantee compatibility between versions Babel 6 and Babel 7 which you are using, so the error happens.

    Solution:

    To solve this error effectively, you need to replace this code:

    "@babel/core": "^7.0.0-beta.40",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "babel-preset-react": "^6.24.1",
    by
    "@babel/core": "^7.0.0-beta.40",
    "@babel/cli": "^7.0.0-beta.40",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-react-transform": "^3.0.0",
    "@babel/preset-react": "^7.0.0-beta.40",

    And

    query: {
    presets: ['react', 'es2015'],
    plugins: ['transform-class-properties']
    }

    should be

    query: {
    presets: ['@babel/react', '@babel/es2015'],
    plugins: ['@babel/proposal-class-properties']
    }

    I did not see @babel/proposal-class-properties in your package.json, but if it is there, it also should be updated.

    • 20
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Maël Valentin
    2022-05-25T20:03:19+00:00Added an answer on May 25, 2022 at 8:03 pm

    It happened to me, and the solution was simple: uninstall [email protected]^/@babel/core

    npm uninstall --save babel-loader
    npm uninstall --save @babel/core

    … then install version 7 of the babel-loader

    npm install --save-dev [email protected]^7
    • 24
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.