'babelHelpers.asyncToGenerator is not a function' error

不羁的心 提交于 2019-12-13 09:00:11

问题


Expected Behavior

App to load as it does on android.

Actual Behavior

Error: babelHelpers.asyncToGenerator is not a function

Environment:

OS: macOS Sierra 10.12.1
Node: 7.9.0
Yarn: 0.20.3
npm: 4.2.0
Watchman: 4.9.0
Xcode: Xcode 8.3.3 Build version 8E3004b
Android Studio: 2.3 AI-162.4069837

回答1:


Check your .babelrc file. Is it including the babel transform-async-to-generator plugin? If so, remove it. The babel helpers that React Native includes do not include the helper for that transform. I'm not sure how to add it without generating a new set of helpers and including them in your build. If that plugin is not in your babel config, maybe one of the library dependencies you are using has it.




回答2:


So I use expo with my project and I had this exact same issue a few days ago, was bothering the hell out of me... ultimately fixed it by importing the library - babel-plugin-transform-async-to-generator

Here is my babelrc file for reference though: `

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": [
        "transform-async-to-bluebird",
        "transform-async-to-generator",
        "transform-react-jsx-source",
        [
          "module-resolver",
          {
            "root": ["./src"]
          }
        ]
      ]
    },
    "production": {
      "plugins": [
        "transform-async-to-bluebird",
        "transform-async-to-generator",
        "transform-remove-console",
        "transform-react-jsx-source",
        [
          "module-resolver",
          {
            "root": ["./src"]
          }
        ]
      ]
    }
  }
}
`


来源:https://stackoverflow.com/questions/46708201/babelhelpers-asynctogenerator-is-not-a-function-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!