How to use gltfloader in nodejs

i need to use gltfloader in nodejs,i want to get glb model and deal with the glb to get some data and output this data in nodejs,i find create mesh is ok,but loader model cannot success ,i try something but not good,Anybody has a working solution?or
recommend me some example about threejs use gltfloader in nodejs

//glb model: t1.glb  
//three r145  type:module
import * as THREE from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
const scene = new THREE.Scene();
var geometry = new THREE.BoxGeometry(100, 100, 100); 
var material = new THREE.MeshLambertMaterial({
	color: 0x0000ff
}); 
var mesh = new THREE.Mesh(geometry, material);
//success
scene.add(mesh); 

//how to scene.add(glb model?)




see doc

see examples

i try to load with gltfloader.parse:

let content=fs.readFileSync(file);
const gltfloader=new GLTFLoader();
gltfloader.parse(content,'',function(gltf){
	scene.add(gltf.scene);
},function(){
	console.log('model load error')
});

but put:

undefined:1
glTF
^

SyntaxError: Unexpected token g in JSON at position 0
    at JSON.parse (<anonymous>)
    at GLTFLoader.parse (file:///D:/work/20221012/node_modules/three/examples/jsm/loaders/GLTFLoader.js:315:21)
    at file:///D:/work/20221012/test.js:22:12
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

the problem also happend in my project,how to give a resolution.

it’s not easily possible. gltfloader relies on web xhr fetch requests and web workers to function. i’ve seen people try to emulate this under node but i haven’t seen something that actually works.

if with “some data” you mean structural data there could be a way. i have forked the loader here GitHub - pmndrs/gltfjsx: 🎮 Turns GLTFs into JSX components this is a node tool, it allows me to read out all structural data, the scene, materials, all props, positions, userData, etc, i have removed everything that had to do with texture and geometry buffers to make it work. the loader is under /src/bin

there is also the GitHub - donmccurdy/glTF-Transform: glTF 2.0 SDK for JavaScript, TypeScript, and Node.js. project. it can parse and process gltfs under node. this is most likely the best solution but i have only ever used the transforms, i haven’t used it to parse files or looked into the code to see how it works. @donmccurdy has made it.

last but not least, if you want to actually display the results in some way i would suggest you use puppeteer, a headless browser environment for node.