Well this might not be exactly the full answer, but it may guide you in the right direction: Take a look at which provide a way to pass code to nodejs (even though it is about server side rendering, the principle is similar). Then you can pass arguments to nodejs the "same way" you may pass it through CLI.

Related Query

More Query from same tag