question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

I’m trying to use babel-loader to pack some imported functions to export it to firebase, but the same error is happening every time.

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

I just don’t know what to try anymore.

webpack.config.js

module.exports = {
  entry: './src/index.js',
  output: { path: __dirname, filename: 'index.js' },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  }
}

Full error

ERROR in ../src/components/services/index.js
Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.
    at createDescriptor (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-descriptor
s.js:158:11)
    at C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-descriptors.js:101:12
    at Array.map (<anonymous>)
    at createDescriptors (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-descripto
rs.js:100:27)
    at createPresetDescriptors (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-des
criptors.js:92:10)
    at C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-descriptors.js:64:19
    at presets (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-descriptors.js:54:2
5)
    at mergeChainOpts (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-chain.js:293
:68)
    at C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-chain.js:246:7
    at buildRootChain (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\config-chain.js:82:
20)
    at loadConfig (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\config\index.js:50:53)
    at transformSync (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\transform-sync.js:13:36)
    at Object.transform (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\@babel\core\lib\transform.js:20:65)
    at transpile (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\babel-loader\lib\index.js:55:20)
    at Object.module.exports (C:\Users\Gabriel\Projetos\danfy\functions\node_modules\babel-loader\lib\index.js:179:20)
 @ ./src/index.js 9:16-56

…/src/components/services/index.js

export * from './xml.service'
export * from './firebase.service'
export * from './validador.service'
export * from './calculador.service'
export * from './store.service'
export * from './assets.service'
export * from './globals'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:29
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
arthurpfcommented, Aug 9, 2018

I found a solution using babelrc: false under options. Using under query gaves and error.

{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    use: {
        loader: 'babel-loader',
        options: {
            babelrc: false,
            presets: ['@babel/preset-env']
        }
    }
}
3reactions
Tsurycommented, Apr 30, 2018

1+

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preset files are not allowed to export objects - Stack Overflow
js Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. Does anyone know how to solve this?
Read more >
Plugin/Preset files are not allowed to export objects, only ...
I have installed @babel/preset-react. so I am having this error now. ERROR in ./main.js Module build failed (from ./node_modules/babel- ...
Read more >
Fix plugin preset files are not allowed to export objects only ...
if you are facing this error “plugin preset files are not allowed to export objects only functions” The problem is mostly because of...
Read more >
【React】webpackエラー解決方法"Plugin/Preset files are not ...
ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to ...
Read more >
React Native: Plugin/Preset files are not allowed to export ...
I'm new to react-native and I'm trying to set up a project with mobx (using decorators), however I'm getting the following error when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found