0
votes

ERROR in ./ClientApp/Client.js Module build failed (from ./node_modules/babel-loader/lib/index.js):

Error: Plugin/Preset files are not allowed to export objects, only functions.

{
  "name": "misreact",
  "version": "1.0.0",
  "description": "",
  "path": "^0.12.7",
  "main": "HelloWorld.js",
  "dependencies": {
     "@babel/core": "^7.1.2",
     "babel-preset-env": "^1.7.0",
     "babel-preset-react": "^6.24.1",
     "babel-preset-stage-2": "^6.24.1",
     "react": "^16.6.0",
     "react-dom": "^16.6.0",
     "webpack": "^4.23.1",
     "webpack-cli": "^3.1.2"
   },
  "devDependencies": {
     "babel-core": "^6.26.3",
     "babel-loader": "^8.0.4",
     "webpack-dev-server": "^3.1.10"
   },
  "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "start:dev": "webpack-dev-server --hot"
   },
  "author": "",
  "license": "ISC"
 }
1
For Babel 7 you need to install @babel/env and @babel/preset-react - Agney
post your babel config. - PlayMa256
run: npm install babel-loader @babel/core @babel/preset-env @babel/preset-react add to: ".babelrc"-file { "presets": [ "@babel/preset-env", "@babel/preset-react" ] } , cheers! - Jimi Pajala
forget to add and StackOverflow dosen't allow to modify answer. Remember to use --dev-flag when installing these compiler stuff since you DO NOT want them in your final bundle. - Jimi Pajala
@JimiPajala tried your suggestion, but came with below error: ERROR in ./ClientApp/Client.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Users\ARMAN\xautopilotdev\misreact\node_modules\babel-preset-stage-2\lib\index.js - autopilot

1 Answers

0
votes

As of Babel 7, stages are deprecated. You can use the following package to update automatically (the following command will run the update with installing babel-update on your computer permanently):

npx babel-upgrade --write

This package is going to install all stage-2 updates (each updates is an individual package now). You may want to consider what updates you actually need and remove the rest.

I would upgrade to @babel/env and @babel/preset-react as well, as mentioned in the comments.