Anyone know how to pass command line arguments to ...
# javascript
p
Anyone know how to pass command line arguments to my kotlin node application? I had no luck with either
./gradlew run myargs
or
./gradlew run --args='myargs'
b
Cant you just build it and run as normal eith node?
p
you mean by calling node an supplying the path to the js file? I tried but path to the dependencies was wrong
b
Do you have any npm dependencies? Did you call node on kompiler output or webpack output?
You either need to provide node_modules or use webpack output
p
I called node on the compiler output
b
See the above
p
how would I go about using the webpack output? I did not see the folder
b
Run gradlew build and look for build/distributions
p
there is no such folder
b
Not sure if it's being generated for node projects
I see
Then you can add my https://gitlab.com/lt.petuska/npm-publish plugin and run gradlew assemble.
Then look for build/publications/xxx and run npm install there. Afterwards you should be able to run node mymodule.js from that dir
Hope that makes sense
Let me know how it goes
p
I figured out a way without the plugin
b
Mind sharing it?
p
in build/js/packages/mymodule there is a package.json, it should be the root directory for node. The package.json contains the path to the entrypoint in the
main
property (as it should). If
"main": "kotlin/example.js"
the whole thing becomes
node build/js/packages/mymodule kotlin/example.js arg1 arg2
🎉 1
maybe there is a way to tell node to run whatever is in the package.json, but I am not sure how and a quick search yielded no results. The above works fine for what I need