three.js three-nodes showing 'Module not found' error

Viewed 58

./node_modules/three/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js Module not found: Can't resolve 'three-nodes/core/CodeNode.js'. I am using react, import three from node_modules, It throws an error like this.

What can I do to solve it?

Why "three-nodes/": "./jsm/nodes/" ?

1 Answers

I think this GitHub Issue is relevant: https://github.com/mrdoob/three.js/issues/24377

three-nodes is an alias of three/examples/jsm/nodes, therefore, if you have this issue you need to make your program recognize this alias. You can find way to do it in Vite from this reply, or in rollup from the following config (with support of @rollup/plugin-alias)

{
    ...,
    plugins: [
        ...,
        alias({
            entries: [
                { find: 'three-nodes', replacement: 'three/examples/jsm/nodes' }
            ]
        })
    ]
}
Related