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/Ways to resolve the error - plugin/preset files are not allowed to export objects, only functions
Next
Answered
Mavis Gelbero
  • 8
Mavis Gelbero
Asked: May 18, 20222022-05-18T19:49:54+00:00 2022-05-18T19:49:54+00:00In: javascript

Ways to resolve the error – plugin/preset files are not allowed to export objects, only functions

  • 8

. Advertisement .

..3..

. Advertisement .

..4..

I’m building a new program, but when I run it, an error pops up. The error displayed is as follows:

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

I have tried several workarounds, but they still do not get the desired results. If you have come across this situation and have a solution for the “plugin/preset files are not allowed to export objects, only functions” problem, pls let me know. Here is what I do:

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"
 }

Thanks!

not allowed to export objects
  • 2 2 Answers
  • 630 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    hdtutoria Expert
    2022-06-20T01:06:37+00:00Added an answer on June 20, 2022 at 1:06 am

    The cause: The babel-preset-react-optimize preset you’re using is currently incompatible with Babel 7.

    The solution: To solve this problem,

    "@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",

    should be

    "@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']
    }

    would be

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

    @babel/proposal-class-properties should also be updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Louis Bernier
    2022-05-25T20:58:04+00:00Added an answer on May 25, 2022 at 8:58 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
    • 12
    • 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.