root.skeleton.getBoneByName is not a function

When using clipAction on a cloned animation fbx on a cloned character model, I get the following error:

Uncaught (in promise) TypeError: root.skeleton.getBoneByName is not a function
    at Function.findNode (three.js:31518)
    at new PropertyBinding (three.js:31447)
    at Function.create (three.js:31456)
    at AnimationMixer._bindAction (three.js:32670)
    at AnimationMixer.clipAction (three.js:33007)

After console.log the characterModel, there seemed to be no issues in the object, it looked like a normal Group, so what is causing this error?

Here is the clone method brought from here: Clone an already-loaded FBX model in three.js and be able to animate it. Adapted from: ยท GitHub

const cloneFbx = (fbx) => {
  const clone = fbx.clone(true)
  clone.animations = fbx.animations
  clone.skeleton = { bones: [] }

  const skinnedMeshes = {}

  fbx.traverse(node => {
      if (node.isSkinnedMesh) {
          skinnedMeshes[] = node

  const cloneBones = {}
  const cloneSkinnedMeshes = {}

  clone.traverse(node => {
      if (node.isBone) {
          cloneBones[] = node

      if (node.isSkinnedMesh) {
          cloneSkinnedMeshes[] = node

  for (let name in skinnedMeshes) {
      const skinnedMesh = skinnedMeshes[name]
      const skeleton = skinnedMesh.skeleton
      const cloneSkinnedMesh = cloneSkinnedMeshes[name]

      const orderedCloneBones = []

      for (let i=0; i<skeleton.bones.length; i++) {
          const cloneBone = cloneBones[skeleton.bones[i].name]

          new THREE.Skeleton(orderedCloneBones, skeleton.boneInverses),

      // For animation to work correctly:

  return clone

and the code causing the error

const characterModel = cloneFbx(characterModelRaw);
const deathAnimation = cloneFbx(animationFBXs["death.fbx"]);
const deathAnimationMixer = new THREE.AnimationMixer(characterModel);
const death = deathAnimationMixer.clipAction(deathAnimation.animations[0]);

animationFBXs is an object mapping the name of the animation to the imported FBX file of the animation. And characterModelRaw is an imported character model.

Replace the cloneFbx with a new cloneFbx method. The one I initially used seems to be outdated (made in 2017).
The clone method is imported from

import {clone} from ""

function cloneFbx(fbx) {
  const fbxClone = clone(fbx);
  fbxClone.animations = fbx.animations;
  return fbxClone;