COMMUNITY

Javascript system platform

When compiling to javascript I get the follow error message:

Accessing this field requires a system platform (php,neko,cpp,etc.)

class Main {
  static function main() {
    trace("hello " + Sys.args()); // <---
  }
}

I understand that the Sys is not compatible with js as given this so answer

What are the alternatives though when working in the js target? Is it not possible to pass in command line?

Node.js has it: javascript - How do I pass command line arguments to a Node.js program? - Stack Overflow

Right now my only single use case is a sample I am working on which prints the program’s path on some targets to showcase multi cross compilation feature of haxe.

It would be nice to hear more of, node.js, browser and the Sys package as well as passing command line arguments and to what extend it might possible or if there is some workaround?

You can target nodejs with haxe hxnodejs library

1 Like

If you want to use system related APIs like that, you’ll have to download the haxe nodejs externs haxelib install hxnodejs and add it as a library to your project compilation, via -lib hxnodejs. Without this library, the javascript target for haxe only supports functionality available directly from the browser.