Why I "import {If} from 'three/nodes'",its error ‘The requested module '/node_modules/.vite/deps/three_nodes.js?v=fdd2419d' does not provide an export named 'If'’

The example you shared is using import maps which defines the directory required as three/nodes…

"imports": {
	"three": "../build/three.module.js",
	"three/addons/": "./jsm/",
	"three/nodes": "./jsm/nodes/Nodes.js"
}

To achieve the import in vite you would use the absolute path name eg…

three/examples/jsm/nodes/Nodes.js