Vite error with optimized info should be defined when use GLTFLoader in React(ThreeJS)

Viewed 3454

I use vite to build one react environment. When I import GLTFLoader from three module, and vite commandline mentioned that Vite Error, /node_modules/.vite/deps/three_examples_jsm_loaders_GLTFLoader.js?v=9d4ee121 optimized info should be defined. Here are codes:

import * as Three from "three"
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'


...

const gltfLoader = new GLTFLoader()
    gltfLoader.setPath('public/')
    gltfLoader.load('000.hdr', gltf => {
        gltf.scene.scale.set(0.2,0.2,0.2)

        scenes.add(gltf.scene)
    })

Here are error message: enter image description here

2 Answers

For others in the future, YMMV: deleting node_modules and pnpm-lock.yaml solved the issue.

Already solve this question.

When the commandline mentioned vite error, just need to close dev-server, then reload. Vite would clean the cache tmp files in .vite.

Related