"no exported member" errors when using NodeNext module/moduleResolution in TypeScript
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 858
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
threeversion: n/a@types/threeversion: n/athree-stdlibversion: 2.29.4
Problem description:
I ran into this bug and it took a while to figure out. It turns out that this library (as well as threes-stdlib) are not compatible with "NodeNext" module/moduleResolution, e.g. if you tsconfig.json looks like this:
"module": "NodeNext",
"moduleResolution": "NodeNext",
And you try to use this library like this:
Code:
import { GLTF, GLTFLoader } from 'three-stdlib'
You will get compile errors via TSC like this:
src/Scene.tsx:17:16 - error TS2305: Module '"three-stdlib"' has no exported member 'GLTFLoader'.
You can work around the bug by switching your tsconfig.json to something like this instead:
"module": "ESNext",
"moduleResolution": "Node",
Relevant code:
Included in the above description.
Suggested solution:
I suspect there is some way to fix this? But I do not yet know. One clue is that @react-three/fiber and @react-three.drei work properly with these tsconfig.json settings.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported import from src/Scene.tsx with the NodeNext settings in tsconfig.json and run TSC. Compare the package's exported types with the behavior under NodeNext module resolution. Done means GLTF and GLTFLoader compile as exported members without requiring the ESNext/Node workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- three.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100