Reputation: 203
Can I run one node js file two times with arguments passed on in the command line. say the file is main.js, Can I do node main.js 1
and node main.js 2
in two separate lines to run two files in separate threads.
Upvotes: 1
Views: 35
Reputation: 51886
Yes, you can. However if you want to do this on the same command prompt window, you must background the first one:
> node main.js 1 &
> node main.js 2
I don't recommend this though unless you want to go into the task manager to kill the first one, or you're proficient enough to get its pid and kill
it.
Running node.js files with the extension is optional. You can simply do this:
> node main 1
Upvotes: 2