यह वास्तव में क्रूर है। मुझे अपने कोड में कहीं भी नहीं मिल रहा है, जहां मैं कुछ भी अवैध कर रहा हूं, लेकिन किसी कारण से, fork
पर कॉल करना मेरे प्रोग्राम को उड़ाता है। कोड यहाँ है। प्रासंगिक भाग svgToPNG में है जहां मैं fork
पर कॉल करता हूं।कॉफ़ीस्क्रिप्ट अप्रत्याशित टोकन ILLEGAL, लेकिन कुछ भी अवैध नहीं होना चाहिए
{fork} = require 'child_process'
{Coral} = require 'coral'
svgToPNG = (svg, reply, log) ->
log "converting SVG to a PNG"
# set up a child process to call convert svg: png:-
convert = fork '/usr/bin/env', ['convert', 'svg:', 'png:-']
log "Spawned child process running convert, pid " + convert.pid
# set up behavior when an error occurs
convert.stderr.on "data", ->
log "Error occurred while executing convert"
reply "error"
# set up behavior for when we successfully convert
convert.stdout.on "data", ->
log "Successful conversion! :)"
log "here's the data: " + data
reply data
# pipe the SVG into the stdin of the process (starting it)
convert.stdin.end svg
अगर मैं fork
लाइन बाहर ले जाना और कुछ और के साथ बदलने, सब कुछ hunky डोरि है, लेकिन अगर मैं इसे में छोड़ देते हैं, मैं:
> coffee src/coral_client.coffee
finished doing conversion to svg!
converting SVG to a PNG
Spawned child process running convert, pid 60823
/usr/bin/grep:1
(function (exports, require, module, __filename, __dirname) { ����
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
यह कोई मतलब नहीं है। मेरे पास this question में कोई अजीब गैरकानूनी यूनिकोड चरित्र नहीं है, मुझे विश्वास नहीं है कि मेरे पास this one में किसी प्रकार की पार्स त्रुटि है ... मुझे वास्तव में पता नहीं है कि क्या हो रहा है।
क्या यह हो सकता है कि कॉफीस्क्रिप्ट किसी भी तरह कोड को तोड़ रहा है? ऐसा लगता है कि वास्तव में असंभव है, लेकिन मुझे नहीं पता।
आप किस फाइल को परिवर्तित कर रहे हैं? इसे एसवीजी रूपांतरित नहीं करना चाहिए: somefilename png: -'? – hpaulj
क्या आपने इस स्क्रिप्ट को संकलित करने का प्रयास किया है, और फिर 'ns' के साथ 'js' चलाएं? यदि 'जेएस' अच्छा दिखता है तो समस्या कॉफ़ीस्क्रिप्ट के साथ नहीं है। – hpaulj
@ hpaulj svg फ़ाइल प्रक्रिया के मानक इनपुट में पाइप किया गया है। –