Error Babel: repl: We found a path that is not an instance of NodePath. Apparently due to poor serialization

When you run a piece of code (taken from an MDN page regarding a keyword letin ES2015) using the online Babel transpiler , it fails with the following error:

repl: We found a path that isn't a NodePath instance. Possiblly due to bad serialisation.

the code

var list = document.getElementById("list");

for (var i = 1; i <= 5; i++) {
  var item = document.createElement("LI");
  item.appendChild(document.createTextNode("Item " + i));

  let j = i;
  item.onclick = function (ev) {
    console.log("Item " + j + " is clicked.");
  };
  list.appendChild(item);
}

Why does an error occur and what can I do?

+4
source share

All Articles