在节点execcallback响应不正常工作

我有一个路由,处理一个url post请求里面我运行一个bash命令的执行。 出于某种原因,console.log工作,所以我知道bash命令结束和callback正在进入。 但是,回应不会让我发送任何东西。 如果我将响应移到execcallback的范围之外,则数据将被我的客户端发送和接收。 现在响应不发送任何东西。 我也没有得到一个错误。

router.post('/someurl', function (req, res) { exec('some command', function (error, stdout, stderr) { if(error) { console.error('exec error: '+error); } console.log(stdout); res.send(stdout); }); }); 

response未定义的 ,你正试图调用它的方法,所以使用res因为它出现在路由处理程序作为参数function(req, res){...}

 res.send(stdout);