Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript index.js .babelrc error "Do not clone comments tha...<omitted>... } could not be cloned"

Update: the error seems to be related to the .babelrc file I had:

{
    "presets": ["env", "react"],
    "plugins": ["transform-class-properties", "transform-object-rest-spread"]
}

When I remove this file, the error disappears.

Original Post:

I am using React with Parcel-bundler. First, I had an issue which had to do with an incompatibility of my parcel version and @babel/preset-env (Invalid version: undefined).

I resolved by adding a resolutions tag to the package.json file to enforce usage of a previous version of Babel which does not require a version object. This worked, but now I get the following error when I build the client

npm run clean && parcel build client/src/index.html --out-dir client/dist:

.../client/src/index.js: function __clone() { var node2 = new Node(); for (var key in this) {// Do not clone comments tha...omitted... } could not be cloned.

...

at Object.serialize (v8.js:202:7)

I searched here and in google, but cannot find this error anywhere.

Any idea what that might be?

For reference, here some excerpts from package.json:

"dependencies": {
    "babel-core": "^6.26.3",
    "body-parser": "^1.18.3",
    "elliptic": "^6.4.1",
    "express": "^4.16.3",
    "hex-to-binary": "^1.0.1",
    "history": "^4.7.2",
    "npm-force-resolutions": "0.0.10",
    "parcel-bundler": "^1.10.3",
    "pubnub": "^4.21.6",
    "react": "^16.6.0",
    "react-bootstrap": "^0.32.4",
    "react-dom": "^16.6.0",
    "react-router-dom": "^4.3.1",
    "redis": "^2.8.0",
    "request": "^2.88.0",
    "uuid": "^3.3.2"
  },
  "resolutions": {
    "@babel/preset-env": "7.13.8"
  }   

and 

"devDependencies": {
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "cross-env": "^5.2.0",
    "jest": "^23.6.0",
    "nodemon": "^1.18.4"} 


  
like image 232
floripa Avatar asked Mar 27 '21 16:03

floripa


1 Answers

Thank you. I have been trying to solve this problem all weekend and simply removing the .babelrc, then replacing it after running 'parcel index.html', seems to have fixed it. Parcel 7+ claims to no longer need babel configuration, so setting it up in .babelrc might have confused the initial cloning process.

like image 135
Jazzyspoon Avatar answered Oct 05 '22 23:10

Jazzyspoon