【发布时间】:2019-03-18 20:00:42
【问题描述】:
失败的插件是@babel/plugin-transform-regenerator(无边缘插件,160 万次下载/周)。
这是我的全部.babelrc:
{
"presets": [],
"plugins": [
"@babel/plugin-transform-regenerator"
]
}
当我尝试使用parcel build source/main/index.html --no-source-maps --out-dir build 将其与包裹一起转译时,我收到以下错误:
/path/to/index.js: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.
plugins: [
['some-plugin', {}],
['some-plugin', {}, 'some unique name'],
]
at assertNoDuplicates (/.../node_modules/@babel/core/lib/config/config-descriptors.js:205:13)
at createDescriptors (/.../node_modules/@babel/core/lib/config/config-descriptors.js:114:3)
at createPluginDescriptors (/.../node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
at alias (/.../node_modules/@babel/core/lib/config/config-descriptors.js:63:49)
at cachedFunction (/.../node_modules/@babel/core/lib/config/caching.js:33:19)
at plugins.plugins (/.../node_modules/@babel/core/lib/config/config-descriptors.js:28:77)
at mergeChainOpts (/.../node_modules/@babel/core/lib/config/config-chain.js:314:26)
at /.../node_modules/@babel/core/lib/config/config-chain.js:278:7
at buildRootChain (/.../node_modules/@babel/core/lib/config/config-chain.js:68:29)
at loadPrivatePartialConfig (/.../node_modules/@babel/core/lib/config/partial.js:85:55)
这是我的 package.json 版本:
"@babel/core": "^7.1.2",
"@babel/plugin-transform-regenerator": "^7.0.0",
有什么想法吗?
【问题讨论】:
-
我从来没有使用过这个,但从给出的例子来看,你可以尝试用
"plugins": ["@babel/plugin-transform-regenerator", {}]修复它。虽然我非常怀疑这会很重要。一种解决方法可能是使用"plugins": ["@babel/plugin-transform-regenerator", {}, 'some-random-name'],所以至少你要给它一个唯一的名称。 -
@icecub 这可能会奏效,但会发生这样的事情真的很奇怪......重复的插件来自哪里?
-
通过一些研究我可以发现,您可能有几个默认插件也在此插件内部使用。这会导致上述错误。
-
@icecub 请将其作为答案,以便我可以接受它以供网络上的其他人参考。
标签: javascript npm babeljs parceljs