Why is `args` of `main` function in kotlin/js alwa...
# javascript
a
Why is
args
of
main
function in kotlin/js always empty when running on nodejs?
Copy code
fun main(args: Array<String>) = println(args.size)
// always prints 0
To access command line arguments I should do something like:
Copy code
@JsModule("process")
external object process {
    val argv: Array<String>
}
fun main() = println(process.argv.sliceArray(2 until process.argv.size))
Not a super convenient way. And it is defferent from the other platforms.
g
Kotlin doesn't target node.js, only generic js, so doesn't have integration with node.js process out of the box