My code is run both in the browser (as bundles) and in nodejs (initial page rendering)
In webpack everything bundles fine and executes fine on the browser.
But when I import OrbitControls.js in NodeJS like so:
const OrbitControls_1 = require("three/examples/jsm/controls/OrbitControls");
It gives the following error:
C:\web\resourceful\daCore\node_modules\three\examples\jsm\controls\OrbitControls.js:10
import {
^
SyntaxError: Unexpected token {
examples/jsm/controls/OrbitControls.js
is a ES6 module so you can’t import it viarequire
.It’s probably best if you use
esm
and ES6 import syntax for your node script similar to obj2three.js.Please use the forum if you need more help.