flyover / imgui-js

JavaScript bindings for Dear ImGui using Emscripten and TypeScript
https://flyover.github.io/imgui-js/example/
MIT License
962 stars 103 forks source link

Build broken under windows and wsl #22

Open apache-hb opened 4 years ago

apache-hb commented 4 years ago

while following the build instructions. when running make the build errors with

npm run start-example-node

> imgui-js@1.0.0 start-example-node /mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js
> node example/index.js

(node:13175) UnhandledPromiseRejectionWarning: ReferenceError: __dirname is not defined
    at ModuleNamespace.<anonymous> (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/bind-imgui.js:8:1038)
    at Promise (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/imgui.js:17:29)
    at new Promise (<anonymous>)
    at Object.<anonymous> (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/imgui.js:16:20)
    at Generator.next (<anonymous>)
    at file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/imgui.js:9:75
    at new Promise (<anonymous>)
    at __awaiter (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/imgui.js:5:16)
    at Object.default_1 [as default] (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/imgui.js:15:16)
    at ModuleNamespace.<anonymous> (file:///mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/example/main.js:22:32)
(node:13175) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:13175) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 

__dirname can be replaced by hand with process.cwd() which then reveals another error:


npm run start-example-node

> imgui-js@1.0.0 start-example-node /mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js
> node example/index.js

{ ENOENT: no such file or directory, open '/mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/main.js'
  Instantiating /mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/main.js
  Loading ./main
  Error: ENOENT: no such file or directory, open '/mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/main.js'
  originalErr:
   { Error: ENOENT: no such file or directory, open '/mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/main.js'
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/mnt/c/Users/ehb56/OneDrive/Documents/GitHub/Timeline/imgui-js/main.js' } }```
flyover commented 4 years ago

Try it with e7b86a2e57f1b8f48f9b4d66940be64f8b9f9fa1. I've only tested on OSX, but it should also work for Windows.