Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Babel 7失败,一个插件说;检测到重复的插件/预设。”;_Javascript_Npm_Babeljs_Parceljs - Fatal编程技术网

Javascript Babel 7失败,一个插件说;检测到重复的插件/预设。”;

Javascript Babel 7失败,一个插件说;检测到重复的插件/预设。”;,javascript,npm,babeljs,parceljs,Javascript,Npm,Babeljs,Parceljs,失败的插件是(没有边缘插件,每周下载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 plugi

失败的插件是(没有边缘插件,每周下载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 registrator”,{},“unique name”]
这是一个巴贝尔错误,基本上是说您已经定义了两次插件
@babel/plugin transform registrator
,或多或少是间接定义的

包裹捆扎机使用Babel预设传送您的代码
@Babel/preset env
。这些预设通常只是可共享的插件列表。正如您所看到的,
preset env
已经在babel 7中包含了
“@babel/plugin transform registrator”

简单的解决方案是:只需从
.babelrc
中的插件配置中删除
“@babel/plugin transform regulator”

PS:在从版本6迁移到版本7之后,有过类似的经历。我的旧配置如下所示(在Babel 6中有效)

我不得不删除插件
transformobjectrest-spread
transformasync-generator函数
transformasync-to-generator
,正如前面所说,这些插件包含在
env
中(此处明确指定)

Babel提供了一个很棒的升级工具,名为
Babel upgrade
(惊喜,惊喜),它确实很好地完成了重命名插件的工作,但不幸的是,它让我独自处理这些“副本”


希望有帮助。

我从来没有使用过这些工具,但从给出的示例来看,您可以尝试使用
“plugins”修复它:[“@babel/plugin-transform-registrator”,{}]
。尽管我非常怀疑这是否重要。一种解决方法可能是使用
“plugins”:[“@babel/plugin transform retinator”,{},'某个随机名称]
,所以至少您给它起了一个唯一的名称。@icecub可能会起作用,但这样的事情竟然发生了,真的很奇怪。。。复制的插件从哪里来?通过做一点研究,我发现有可能你有一些默认插件,这些插件也在内部使用。这就导致了上面提到的错误。@icecub请回答这个问题,这样我就可以接受它,让网络上的其他人都有一个参考。
  "plugins": [
    "react-hot-loader/babel", 
    "transform-object-rest-spread", 
    "transform-class-properties", 
    "transform-runtime",
    "transform-async-generator-functions",
    "transform-async-to-generator"
  ],
  "presets": ["env", "react"]