程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”?

开发过程中遇到Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”的问题如何解决?下面主要结合日常开发的经验,给出你关于Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”的解决方法建议,希望对你解决Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”有所启发或帮助;

当我尝试使用parcelJs 创建构建时出现以下错误。它在使用 Parcel 创建构建时显示了一些 babel 文件:

    yarn run v1.22.5
$ parcel build app.HTML -d static
?  /home/documents/ClIEnt-Portal/react/react-entry.Js: function __clone() {
    var node2 = new Node();
    for (var key in this) {
      // Do not clone comments tha...<omitted>... } @R_404_5717@ not be cloned.
    var node2 = new Node();
    for (var key in this) {
      // Do not clone comments tha...<omitted>... } @R_404_5717@ not be cloned.
    at Object.serialize (v8.Js:268:7)
    at _default (/home/documents/ClIEnt-Portal/node_modules/@babel/core/lib/transformation/util/clone-deep.Js:16:30)
    at normalizefile (/home/documents/ClIEnt-Portal/node_modules/@babel/core/lib/transformation/normalize-file.Js:52:36)
    at normalizefile.next (<anonymous>)
    at run (/home/documents/ClIEnt-Portal/node_modules/@babel/core/lib/transformation/index.Js:31:50)
    at run.next (<anonymous>)
    at Function.<anonymous> (/home/documents/ClIEnt-Portal/node_modules/@babel/core/lib/transform-ast.Js:20:41)
    at Generator.next (<anonymous>)
    at evaluateSync (/home/documents/ClIEnt-Portal/node_modules/gensync/index.Js:251:28)
    at Function.sync (/home/documents/ClIEnt-Portal/node_modules/gensync/index.Js:89:14)
[1/4] Resolving packages...
error Command Failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command

我正在使用 babel-core "^6.18.2"parcel ^1.12.5"节点 ^12.18.2“反应”:“15.4.2”。 我的反应入口文件如下:

import AppRoutes from './components/app/AppRoutes';

// Legacy browser polyfills (e.g. IE 11)
import 'whatwg-fetch'; // Fetch polyfill
import Promise from 'promise-polyfill'; // Promise polyfill
if (!window.PromisE) window.Promise = Promise;

// HTML Events for IE
if (navigator.userAgent.indexOf('MSIE') !== -1 
  || navigator.appVersion.indexOf('TrIDent/') > 0) {
    window.fireEvent = (E) => {
      let evt = document.createEvent("HTMLEvents");
      evt.initEvent(e,true,falsE);
      window.dispatchEvent(evt);
    }
} else {
  window.fireEvent = (E) => window.dispatchEvent(new Event(E));
}

// Custom Event polyfill
if (typeof window.CustomEvent !== "function") {
  function CustomEvent ( event,params ) {
    params = params || { bubbles: false,cancelable: false,detail: undefined };
    var evt = document.createEvent( 'CustomEvent' );
    evt.initCustomEvent( event,params.bubbles,params.cancelable,params.detail );
    return evt;
  }

  CustomEvent.prototype = window.Event.prototype;
  window.CustomEvent = CustomEvent;
}

window.onload = () => {
  ReactDOm.render(<AppRoutes/>,document.getElementByID('main'));
};

解决方法

我已删除 .babelrc 文件,然后能够成功创建构建。

大佬总结

以上是大佬教程为你收集整理的Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”全部内容,希望文章能够帮你解决Parcel 构建失败,显示 babel 错误“Do not clone comments tha...<omitted>... } could not be cloned”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。