我遇到了一个晦涩的错误 ENOENT。这是输出。
converting SVG to a PNG
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
这是代码。检查 print 语句,它似乎发生在调用child.spawn
.
child = require 'child_process'
svgToPNG = (svg, reply, log) ->
# set up a child process to call convert svg: png:-
log "converting SVG to a PNG"
convert = child.spawn 'convert', ['svg:', 'png:-']
convert.stderr.on 'data', (data) ->
log data.toString()
convert.stdout.end data
return reply "error occurred"
# create buffer that output will be piped into
res = ""
# pipe this process' stdout into res
convert.stdout.pipe res
# pipe svg into the process and close its input, startin the process
convert.stdin.end svg
# call reply with the res as content
log "OK done converting to a PNG, replying"
reply res
convert
从命令行调用工作得很好。我不确定为什么会失败。