 <p>I suggest that you use child_process.spawnSync which is a blocking call and returns ONLY after the process is complete. In addition, the object returned includes an error <strong>property</strong> that contains the code.</p> <p>But in all cases - spawn or spawnSync, etc, I believe the result object always includes an error object if the sub-process fails for any reason. So checking for the existence of this object is probably enough.</p>