Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'nodegame-client': but where should I put the game file? #125

Closed
lieuzhenghong opened this issue Feb 20, 2020 · 12 comments

Comments

@lieuzhenghong
Copy link

lieuzhenghong commented Feb 20, 2020

Dear Stefano,

I've been trying to make the nodeGame setup more portable.

So I have my game in ~/dev/communication-game and I have a symlink in ~/dev/bee-game/nodegame-v5.8.1/games pointing to it.

The problem is that of course ~/dev/communication-game doesn't have any of the node modules, because it's in a different folder than the one I installed the nodegame versions. Thus when I try to run, I get the following error:

lieu@lieu-ubuntu ~/d/b/nodegame-v5.8.1 (master)> node launcher.js --default communication-game   (base) 
nodeGame v.5.8.1
error: GameLoader.loadClientTypes: an error occurred while reading client type: logic.js. Game: communication-game. Err:
Error: Cannot find module 'nodegame-client'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/lieu/dev/communication-game/game/client_types/logic.js:12:11)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
error: ServerNode caught an exception: 
Error: Cannot find module 'nodegame-client'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/lieu/dev/communication-game/game/client_types/logic.js:12:11)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
warn: GameLoader.loadAuthDir: channel ultimatum: authorization disabled in configuration file
Requirements room created: ultimatum

How should I resolve this?

@shakty
Copy link
Member

shakty commented Feb 20, 2020 via email

@lieuzhenghong
Copy link
Author

Hi Stefano,

Sorry, am not sure what you mean. What exactly do I set?

@lieuzhenghong
Copy link
Author

If there is some documentation, I'd be happy to take a look and understand it.

@shakty
Copy link
Member

shakty commented Feb 20, 2020

Sorry if my message was unclear before, I was typing from my phone. Here is some documentation:

https://github.com/nodeGame/nodegame/wiki/Server-Configuration-v5

however, it is basically a pointer to the file I mentioned before. In your case, you should set the variable gameDirs = [ '/your/full/path/to/the/games/dir/']. However, I am not sure 100% it will solve your problem, let me know.

@shakty
Copy link
Member

shakty commented Feb 20, 2020

If it does not work, you could try to symlink the node_modules directory in /dev/ (should work, but ugly), or you could install the needed modules globally with npm. This latter solution is also not very elegant, because you will still have a local and and global copy of the nodegame modules. Let me know.

@lieuzhenghong
Copy link
Author

So I've set /home/lieu/dev/bee_game/nodegame-v5.8.1/conf/servernode.js to the following:

/**
 * # servernode.js
 *
 * Copyright(c) 2017 Stefano Balietti <ste@nodegame.org>
 * MIT Licensed
 *
 * Configuration file for ServerNode in nodegame-server.
 * ---
 */
module.exports = configure;

function configure(servernode) {
    // Extra configuration goes here, e.g.:
    // servernode.port = 80;
    // servernode.homePage = false;
		gameDirs = ['/home/lieu/dev/communication-game']

    // See the full set of configuration options in:
    // node_modules/nodegame-server/conf/servernode.js

    return true;
}

This did not work. Unless I should be editing the servernode.js file in the node_modules folder instead?

@shakty
Copy link
Member

shakty commented Feb 20, 2020 via email

@lieuzhenghong
Copy link
Author

function configure(servernode) {
    // Extra configuration goes here, e.g.:
    // servernode.port = 80;
    // servernode.homePage = false;
		servernode.gameDirs = ['/home/lieu/dev/communication-game']

    // See the full set of configuration options in:
    // node_modules/nodegame-server/conf/servernode.js

    return true;
}

Still doesn't work, unfortunately. Should I be editing the servernode.js file in the node_modules folder?

@shakty
Copy link
Member

shakty commented Feb 20, 2020 via email

@lieuzhenghong
Copy link
Author

Sorry, I don't understand. From what directory do I add a symlink, and where do I symlink to?

Should I create a symlink from /home/lieu/dev/communication-game pointing to /home/lieu/dev/bee_game/nodegame-v5.8.1/node_modules?

@shakty
Copy link
Member

shakty commented Feb 20, 2020 via email

@lieuzhenghong
Copy link
Author

Ah, adding the symlink seems to work, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants