3

尝试在 CircleCi 上运行构建,但测试失败。同样的东西在我的本地也很完美。我的 .babelrc 配置:

{
  "presets": [
    "es2015",
    "react",
    "stage-2"
  ],
  "plugins": [
    "transform-class-properties",
    "react-hot-loader/babel",
    ["babel-plugin-transform-builtin-extend", {
      "globals": ["Error", "Array"]
    }],
    ["transform-runtime", {
      "polyfill": false,
      "regenerator": true
    }]
  ]
}

我从 circleCI 得到的错误:

yarn test v0.27.5
$ jest 
 FAIL  src/utils/service-helper.test.js
  ● Test suite failed to run

    ReferenceError: [BABEL] /home/circleci/repo/src/utils/service-helper.test.js: Unknown option: /home/circleci/repo/node_modules/react/index.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.

    A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

    Invalid:
      `{ presets: [{option: value}] }`
    Valid:
      `{ presets: [['presetName', {option: value}]] }`

任何想法,因为相同的配置正在另一个项目中工作

4

1 回答 1

6

该错误没有帮助,但问题是您的配置在预设列表中,但它react无法babel-preset-react在您的 . 但是由于该模块不是预设的,所以 Babel 会抛出。node_modulesreact"react"

很可能,您忘记babel-preset-react在您的package.json.

于 2018-06-02T18:30:17.233 回答