gpt4 book ai didi

babeljs - 为什么 Babel 抛出 Unknown option : . .. Children?

转载 作者:行者123 更新时间:2023-12-04 13:10:59 28 4
gpt4 key购买 nike

尝试在 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}]] }`

当相同的配置在另一个项目上工作时,知道发生了什么

最佳答案

报错没有用,问题是你的配置在预设列表里有react,但是找不到babel-preset-react模块你的 node_modules,所以它正在加载 react 模块本身,就好像它是一个预设。但是由于 “react” 模块不是预设,所以 Babel 抛出。

很可能,您忘记了在 package.json 中列出 babel-preset-react

关于babeljs - 为什么 Babel 抛出 Unknown option : . .. Children?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50659921/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com