0

I have inherited a project that hasn't been touched in a few years. So my first step was to upgrade all of the dependencies. I got close to making it work but I am stuck on this one error:

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

I tried removing the rules from my webpack.config.js file. That wasn't much help. The project originally referenced 'es2015' and I updated that information to use 'es2016'.

here's my package.json file

{
  "name": "quant-engine",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "private": true,
  "scripts": {
    "start": "webpack-dev-server --progress --inline --port 8112",
    "build": "webpack",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "acorn": "^6.1.1",
    "babel-core": "^6.17.0",
    "babel-loader": "^8.0.5",
    "babel-preset-es2016": "^6.24.1",
    "babel-preset-react": "^6.5.0",
    "chai": "^4.2.0",
    "css-loader": "^2.1.1",
    "file-loader": "^3.0.1",
    "font-awesome": "^4.7.0",
    "moment": "^2.18.1",
    "prettier": "^1.17.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.8",
    "react-currency-input": "^1.2.6",
    "react-date-picker": "^7.5.1",
    "react-dom": "^16.8.6",
    "react-fontawesome": "^1.6.1",
    "style-loader": "^0.23.1",
    "webpack": "^4.30.0",
    "webpack-dev-server": "^3.3.1"
  },
  "devDependencies": {
    "@storybook/addon-actions": "^5.0.11",
    "@storybook/addon-links": "^5.0.11",
    "@storybook/addons": "^5.0.11",
    "@storybook/react": "^5.0.11",
    "webpack-cli": "^3.3.2"
  }
}

and here's my webpack.config.js file

module.exports = {
  entry: './src/app.js',
  },
  output: {
    path: __dirname,
    filename: 'bundle.js'
  },
  module: {   
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: { presets: [ 'es2016', 'react' ] }
      },
      {
        test: /\.(png|jpg|gif)$/,
        loader: 'file-loader',
        exclude: /node_modules/,
        options: {}
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      }
    ]
  }
};

I'm not familiar with babel. From what I can find, other people have posted this problem with no result (but their questions were never fully explained).

I would like all of the project dependencies to be as current as possible. I do not want to downgrade any as much possible.

Thnx

edit: build output below. I do not have a .babelrc file.

# npm start

> quant-engine@1.0.0 start C:\src\projects\OptionAnalyzer\web
> webpack-dev-server --progress --inline --port 8112

 10% building 1/1 modules 0 activei 「wds」: Project is running at http://localhost:8112/
i 「wds」: webpack output is served from /
× 「wdm」: Hash: c72e7c421021f65f90e2
Version: webpack 4.30.0
Time: 1030ms
Built at: 2019-05-07 14:40:23
    Asset     Size  Chunks             Chunk Names
bundle.js  349 KiB    main  [emitted]  main
Entrypoint main = bundle.js
[0] multi (webpack)-dev-server/client?http://localhost:8112 ./src/app.js 40 bytes {main} [built]
[./node_modules/ansi-html/index.js] 4.16 KiB {main} [built]
[./node_modules/ansi-regex/index.js] 135 bytes {main} [built]
[./node_modules/html-entities/index.js] 231 bytes {main} [built]
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/node-libs-browser/node_modules/events/events.js] 13.3 KiB {main} [built]
[./node_modules/querystring-es3/index.js] 127 bytes {main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8112] (webpack)-dev-server/client?http://localhost:8112 8.26 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built]
[./src/app.js] 1.44 KiB {main} [built] [failed] [1 error]
    + 11 hidden modules

ERROR in ./src/app.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:\src\projects\OptionAnalyzer\web\node_modules\babel-preset-es2016\lib\index.js
    at createDescriptor (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:178:11)
    at items.map (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)
    at passPerPreset (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:58:96)
    at cachedFunction (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\caching.js:33:19)
    at presets.presets (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-descriptors.js:29:84)
    at mergeChainOpts (C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-chain.js:320:26)
    at C:\src\projects\OptionAnalyzer\web\node_modules\@babel\core\lib\config\config-chain.js:283:7
i 「wdm」: Failed to compile.
  • Could you post the verbose error/trace? Also, what does the `.babelrc` file look like? It looks like you're behind a version on Babel (which underwent a significant change from v6 to v7 and is now called `@babel/core`, https://babeljs.io/docs/en/v7-migration). Based on the other posts it seems related to babel, but without more info it's hard to tell. – adamellsworth May 07 '19 at 15:40
  • Added build output. I do not have `.babelrc` file, which I noted in my edit. – react.dude.2 May 07 '19 at 20:42
  • I found the code: https://github.com/babel/babel/tree/6.x/packages/babel-preset-es2016 (looks like it's a wrapper for `babel-plugin-transform-exponentiation-operator`, which if you look exports an Object of "inherits"/"visitor"). So it is deprecated in favor of preset-env (requires Babel ^7) but should work if you use a `.babelrc` file alongside like the readme shows. Otherwise, you'll have to bring all babel-related stuff to the latest ^7 as a "quick" fix. My best guess is the plugin throwing the err is exporting itself in a way which is no longer supported by Babel. – adamellsworth May 08 '19 at 21:28
  • Additionally, this comment on Babel seems to espouse the same approach of updating the dep to the latest version: https://github.com/babel/babel/issues/6808#issuecomment-343792786. It's a dumb way to fix a problem, but here we are. – adamellsworth May 08 '19 at 21:30
  • @adamellsworth if you make your comment the answer I will mark this resolved. Thank you for your help. – react.dude.2 May 10 '19 at 14:13

0 Answers0