How to wait for a child process to finish in Node.js?

后端 未结 5 1357
终归单人心
终归单人心 2021-01-01 10:15

I\'m running a Python script through a child process in Node.js, like this:

require(\'child_process\').exec(\'python celulas.py\', function (error, stdout, s         


        
5条回答
  •  抹茶落季
    2021-01-01 10:29

    You should use exec-sync

    That allow your script to wait that you exec is done

    really easy to use:

    var execSync = require('exec-sync');
    
    var user = execSync('python celulas.py');
    

    Take a look at: https://www.npmjs.org/package/exec-sync

提交回复
热议问题