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

Cannot find module 'phaser3spectorjs' #19

Open kpotschi opened 1 year ago

kpotschi commented 1 year ago

Describe the bug Using a minimal setup, the compilter throws the following error

[1] Error: Cannot find module 'phaser3spectorjs'
[1] Require stack:
[1] - /Users/kevinsensory/Coding/test/node_modules/phaser/src/renderer/webgl/WebGLRenderer.js
[1] - /Users/kevinsensory/Coding/test/node_modules/phaser/src/renderer/webgl/index.js
[1] - /Users/kevinsensory/Coding/test/node_modules/phaser/src/renderer/index.js

the setup looks like this, but is basically pulled from the github documentation, minus the audio flag in the config, it seems to be deprecated.

require('@geckos.io/phaser-on-nodejs')
import Phaser from 'phaser'

// set the fps you need
const FPS = 30
global.phaserOnNodeFPS = FPS // default is 60

// your MainScene
class MainScene extends Phaser.Scene {
    constructor() {
        super('MainScene')
    }
    create() {
        console.log('it works!')
    }
}

// prepare the config for Phaser
const config = {
    type: Phaser.HEADLESS,
    width: 1280,
    height: 720,
    banner: false,
    scene: [MainScene],
    fps: {
        target: FPS,
    },
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 300 },
        },
    },
}

// start the game
new Phaser.Game(config)

I'm able to get it to run commenting out

if (typeof WEBGL_DEBUG)
{
    var SPECTOR = require('phaser3spectorjs');
    DEBUG = true;
}

in node_modules/phaser/src/renderer/webgl/WebGLRenderer.js

yandeu commented 1 year ago

The error looks pretty obvious: Error: Cannot find module 'phaser3spectorjs'

What is phaser3spectorjs btw?

kpotschi commented 1 year ago

it's some sort of debug tool as far as I understand?

Unfortunately this might be above my understanding, but the fact that Phaser itself runs without a problem, but the error shows up when using phaser-on-nodejs, I was wondering if there's some flag that needs to be set in order for WEBGL_DEBUG not to be undefined

yandeu commented 1 year ago

On nodejs there is no WEBGL. So it will always be undefined.

yandeu commented 1 year ago

Ooh wait. Are you running the latest 3.60 Phaser version? This library is not yet adapted to 3.60. Works with Phaser <3.50.0 and >=3.55.2.

Maybe you want to try arcade-physics instead.

ghlds commented 1 year ago

哦等。你运行的是最新的3.60 Phaser版本吗? 这个库还没有配到3.60。 Works with Phaser <3.50.0 and >=3.55.2.

也许你想考机械物理学

I hope it will support the 3.60.0,It's great!

hongha1412 commented 11 months ago

i have the same issue, even when i downgrade phaser version to 3.55.2 or lower, this error still appear when compile

yandeu commented 11 months ago

Related to https://github.com/photonstorm/phaser/issues/6644

yandeu commented 10 months ago

I just released a new version. Try it!