0

あいまいなエラー 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は問題なく機能します。なぜこれが失敗するのかわかりません。

4

1 に答える 1

0

シェルを入力convertすると、シェルは環境変数convert内のディレクトリを検索して、実行可能ファイルへのフル パスを見つけます。それはしません。したがって、絶対パスを使用するか、対話型シェルのように PATH を検索するプログラムを使用します。を使用すると、それがコマンドになり、引数 1 になり、convert の残りの引数がそれに続きます。PATHchild_process.spawnconvert/usr/bin/env/usr/bin/envconvert

于 2013-10-03T21:52:28.967 に答える