How to export Model with Bones with GLTFExporter

Hello could you help me how can I export model which have bones with GLTFExporter in correct way or where I can find info about it.
now I am getting this ERROR

TypeError: Cannot set property ‘isBone’ of undefined
at GLTFParser…/node_modules/three/examples/jsm/loaders/GLTFLoader.js.GLTFParser.markDefs (app.js?1625164794:135270)
at GLTFParser…/node_modules/three/examples/jsm/loaders/GLTFLoader.js.GLTFParser.parse (app.js?1625164794:135220)
at GLTFLoader.parse (app.js?1625164794:133970)
at Object.onLoad (app.js?1625164794:133792)
at XMLHttpRequest. (app.js?1625164794:109090)

If you can share a demo that reproduces this issue, I’d recommend filing a bug at Issues · mrdoob/three.js · GitHub – this is supposed to “just work”, there is no trick to it. GLTFExporter may be producing an invalid glTF file here, if it doesn’t pass glTF Validator after export.

I cant share my project it is huge but I am loading this model from Sketchfab

and I can import this model to three.js editor and export without error but when I try to do it in my project I get that error and I am not doing any fancy stuff

I think you’ll have to share code (even a minimal reproduction case) that does the export then. The editor just uses GLTFExporter, nothing special. If we’ve got one working example (editor) and one broken example (your project) there is something different between them.

So I found my mistake but could not understand why!
At some point I was cloning my model and exporting my cloned model,
but could not understand why it was happening so if you know explanation I would be very thankful if you could explain why.

Cloning a model that contains a SkinnedMesh is not as simple as the usual object.clone() unfortunately – some extra work is required to ensure the new skeleton is set up correctly. SkeletonUtils.clone(object) will do this for you, as long as you clone something that is an ancestor of both the SkinnedMesh and its bones, such as the scene root.