How can I execute a node.js module as a child process of a node.js program?

后端 未结 2 357
北荒
北荒 2020-12-02 10:34

Here\'s my problem. I implemented a small script that does some heavy calculation, as a node.js module. So, if I type \"node myModule.js\", it calculates for a second, then

2条回答
  •  感动是毒
    2020-12-02 10:55

    It doesn't matter what you will use as a child (Node, Python, whatever), Node doesn't care. Just make sure, that your calculcation script exits after everything is done and result is written to stdout.

    Reason why it's not working is that you're using spawn instead of exec.

提交回复
热议问题