Why i can't requrie SceneExporter in node.js?
-
20-12-2019 - |
Вопрос
Hey guys i got a question, when i wanna use SceneExporter in node.js i got some problem with require it i will show examples:
THREE = require 'three' - here i include module which i instaled to node.js
Export = require './SceneExporter.js' - here is js
ERROR: THREE.SceneExporter = function () {}; ^ ReferenceError: THREE is not defined
How can i use it in node.js ?
Maybe some 1 here did it before.
What's more when i try include three.js from file like here:
THREE = require './three.js'
I get other error:
/home/name/NetBeansProjects/SerwerNode/src/three.js:26561
self._typeface_js = { faces: THREE.FontUtils.faces, loadFace: THREE.FontUtils.
^
ReferenceError: self is not defined
Решение
I assume you use this bundle of three.js https://github.com/nulltask/node-three.js
Well, it won't solve your problem, but to the question "Why you can't require SceneExporter ?"
the answer is "because this bundle either is not up-to-date with the original repository or it simply does not include the SceneExporter
class"
So, what is best approach to solve your dependency problem ? I don't have the answer yet, but you should keep an eye on the relevant three.js issue here: https://github.com/mrdoob/three.js/issues/4776
Другие советы
Because node.js does not support window/self, which are Web APIs.