MZ Is NodeJS a dependency or not?

I only own RMMZ and have never used RMMV. I am trying to get SRD Character Creator EX ( http://sumrndm.site/character-creator-ex/ ) working in RMMZ using Fossil ( https://github.com/FossilMZ/fossil-MV-MZ ). If I ever make progress I'll post it in a separate thread 😉

While trying to debug I have come across hints that RMMZ, Fossil and/or SRD CCEX use NodeJS in additional to regular JavaScript. For example, use of the require function.

Is NodeJS a dependency for all RMMZ games? I am able to run my own games from within a browser, so that would surprise me. On the other hands I've only made simple environments, so maybe I just haven't encountered anything that needs NodeJS capabilities.

And/or do some plugin authors just use NodeJS in their plugins? I've noticed that there are a lot of novel approaches to writing plugins, TypeScript, CoffeeScript, obfuscated code, etc.

If NodeJS is a dependency, even sometimes, is there a recommended way to launch games that require it? I launch my games directly in the browser with a fake webserver (mostly without issues). While tinkering I have relied on some WebStorm magic to detect and use NodeJS modules. I would prefer to know what I'm doing 🙂
Hello! Welcome!

I believe that nodeJS is aimed at servers, the web deployment of games made with RMMV or RMMZ does not send any file referring to this Libray.
This only works with permissions that browsers do not have for security reasons, such as creating folders, files, editing and reading, the same happens in the compilation for Android and IOS which then depends on some API like Cordova.

Good luck.
NodeJS is not a requirement for all RMMZ games.

Plugin writers can choose to depend on NodeJS. Depending on NodeJS's file system module fs is alluring as it is much easier to work with.
Take my MoarMaps plugin for example. I created a helper plugin where you can compress maps to save space. In that helper plugin I have a dependency on NodeJS and use its fs module. Compressing the map files is nice and synchrounous:
JavaScript:
compressFile(sourcePath, outputPath) {
    const json = this.fs.readFileSync(sourcePath);
    const zip = pako.deflate(json, { to: "string", level: 1 });
    this.fs.writeFileSync(outputPath, zip);
}

In the plugin that will be in actually released games I need to go the more tedious path of requesting the file with an HTTP request. Having to deal with async calls also increases the difficult and tediousness of writing the code
JavaScript:
DataManager.loadDataZipFile = function(name, src) {
    const xhr = new XMLHttpRequest();
    const url = "data/" + src;
    window[name] = null;
    xhr.open("GET", url);
    xhr.onload = () => this.onXhrZipLoad(xhr, name, src, url);
    xhr.onerror = () => this.onXhrError(name, src, url);
    xhr.send();
};

DataManager.onXhrZipLoad = function(xhr, name, src, url) {
    if (xhr.status < 400) {
        const zip = xhr.responseText;
        StorageManager
            .zipToJson(zip)
            .then(json =>
                StorageManager.jsonToObject(json)
                    .then(map => {
                        window[name] = map;
                        this.onLoad(window[name]);
                    })
            );
    } else {
        this.onXhrError(name, src, url);
    }
};


As you can generated code dynamically and evaluate that there does not exist a surefire way to detect if a given plugin has NodeJS or other specific platform/framework dependencies.
Please note that the existance of the require keyword is not something you can depend on alone to determine dependencies.
You can use the Utils.isNwjs() method to determine if you are currently running in a NodeJS context or not. In SRD's Character Creator EX all the code paths leading to code that calls require looks to be gated by Utils.isNwjs() return true.
@Dev_With_Coffee @Zeriab Now I get it! Node.js is not a strict requirement, but has some benefits for plugin developers.

I eventually figured out that underneath it all, desktop games are relying on NW.js (formerly node-webkit) and that this is not exactly the same as Node.js. (Yes, I'm a JavaScript noob.)

THEN I put together this little guide to help anyone who insists on trying to run everything on Ubuntu even though it isn't officially supported: https://forums.rpgmakerweb.com/index.php?threads/launching-and-debugging-in-ubuntu-webstorm.140188/

Your tips were invaluable. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/is-nodejs-a-dependency-or-not.140165/