Error loading OrbitControls through node.js

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:

import {
SyntaxError: Unexpected token {

Author: Fantashit

1 thought on “Error loading OrbitControls through node.js

  1. const OrbitControls_1 = require(“three/examples/jsm/controls/OrbitControls”);

    examples/jsm/controls/OrbitControls.js is a ES6 module so you can’t import it via require.

    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.

Comments are closed.