Tag: 调用

产生asynchronous执行的JavaScript

我想用代码说明问题: var async1 = f1(params, cb); var async2 = f2(params, cb); 现在我可以通过瀑布asynchronous过程调用async1,如下所示: async.waterfall([ function(cb){ async1(params, cb); async2(params, cb); }, //default process function(result, cb){ //some code here and then cb(null, result); } ], done); 我的问题是我如何等待async1 donecallback,所以我可以调用async2 。 这两个任务都需要运行默认进程和完成callback。 如果有一种方法/devise模式,我可以运行async1和完成后,我可以在同一个瀑布asynchronous函数内运行async2 ? 这两个asynchronous函数都需要完成默认进程和完成callback。 谢谢。

NodeJs exec-php模块,php不是一个命令

我想从我的nodejs文件调用一个php文件。 我已经安装并需要exec-php模块,它已经安装好了。 我得到的错误是: { Error: Command failed: php C:\Users\***\Desktop\nodejs\xxchat11\node_modules\exec-php\lib\php\cli.php -pC:\Users\***\AppData\Local\Temp\tmp-129647qzlx6s.gh55ewmi.tmp -rC:\Users\***\AppData\Local\Temp\tmp-12964 7pid95t.8vpiizfr.tmp 'php' is not recognized as an internal or external command, operable program or batch file. at ChildProcess.exithandler (child_process.js:204:12) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:886:16) at Socket.<anonymous> (internal/child_process.js:342:11) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at Pipe._handle.close [as _onclose] (net.js:501:12) killed: false, […]