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.

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

See original GitHub issue

Bug Report

Environment

"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3"
OSX: 10.13.6 (17G3014)
node -v
v10.0.0
npm -v
5.6.0

Babel Configuration (.babelrc)

{
  "presets": [ "react",  ["env", {
    "targets": {
     "browsers": [ ">0.25%", "not ie 11", "not op_mini all"]
    }
  }], "stage-0" ],
  "env": {
   "production": {
      "presets": ["minify"]
    }
  },
  "plugins": [
    [ "transform-object-rest-spread", { "useBuiltIns": true } ],
    "transform-es2015-destructuring",
    "transform-runtime",
    "transform-decorators-legacy",
    "transform-class-properties"
  ]
}

Want to transform code

import { transform } from '@babel/core'
...
const source = await readFile(fileName)
const posixName = posixPath(fileName)
const result = transform(source, {
  babelrc: true,
  filename: fileName
})

Current Behavior

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

Expected behavior/code Code is successfully transformed regarded to working project with that babel config.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolo-ribaudocommented, Oct 11, 2018

Error: Cannot find module ‘babel/core’

It’s babel-core, not babel/core

Probably some of your dependencies depends on @babel/core, so you are able to import it because it is hoisted by npm.

1reaction
loganfsmythcommented, Oct 11, 2018

Also, FYI we have a transformFile function, so you don’t need to read the file yourself, and converting with posixPath shouldn’t be needed.

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 ...
Hello. I am getting this error. I have seen that there is already about this error. I have tried all but not working...
Read more >
Plugin/Preset files are not allowed to export objects, only ...
Hi there! When I running any tests, i getting: Error: Plugin/Preset files are not allowed to export objects, only functions.
Read more >
React Native: Plugin/Preset files are not allowed to export ...
React Native: Plugin/Preset files are not allowed to export objects, only functions. I'm new to react-native and I'm trying to set up a ......
Read more >
【React】webpackエラー解決方法"Plugin/Preset files are not ...
node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to export objects, only functions.
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