geckosio / phaser-on-nodejs

Allows you to run Phaser 3 game (including Phaser's physics engines) on Node.js
MIT License
102 stars 11 forks source link

Phaser not working in headless mode with "npm geckos.io/phaser-on-node" #3

Closed mreifenberger closed 4 years ago

mreifenberger commented 4 years ago

I tried running phaser on my server in headless mode, and wanted to use your geckos.io/phaser-on-node dependency. After requiring it in my config I still get the error if (window.hasOwnProperty('webkitAudioContext') && ^ ReferenceError: window is not defined

repo to replicate: https://gitlab.com/mreifenberger/phaser3-typescript-multiplayer-template

Thank you for any help, Mika

yandeu commented 4 years ago

I'm sorry but your code does not work. If I remove node_modules and run npm i && npm start, it says Error: Cannot find module './gameConfig'.

Try to add import '@geckos.io/phaser-on-nodejs' on the first line of server.ts.

Also, I recommend you to use a more advanced phaser template like phaser-project-template to get started. Or take a look at the geckos.io and phaser multiplayer game example.

mreifenberger commented 4 years ago

Hello Yannic, thanks for the answer. I tried recloning as you said and it worked fine - the classic. I tried adding it to the first line of server.ts but I still get the same error.

I repushed it in case you wanna try again.

Yes I know that this one is not perfect, but I wanna understand what goes on (by doing it myself first) before I start using other peoples' templates :)

yandeu commented 4 years ago

I see. This is also the way I learned how to use webpack.

I can clone it again and check it. But please first remove the node_modules folder from git and add a .gitignore file with the content /node_modules/.

mreifenberger commented 4 years ago

Thanks for understanding

I pushed it now , without node_modules and the git ignore!

Thank you for your efforts :)

yandeu commented 4 years ago

I fixed it here. There where a LOT of issues. But nothing wrong with phaser-on-nodejs :)

Hope this helps :)

mreifenberger commented 4 years ago

Hi Yannic,

thank you VERY much for looking into that. (Sorry for wasting your time tho now that geckosio runs perfectly fine unlike i said).

It helped me tremendously, thank you :)