2013-10-23 105 views
0

當我運行的濾餅我得到這個錯誤如何解決這個node.js錯誤?

**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)** 

,這是什麼問題的精確解?我試過其他的stackoverflow的anwser,但沒有任何工作。 我已經安裝的的NodeJS和v0.10.21咖啡腳本的1.6.3和使用Windows 32位系統 對於一個例子,我在我的cakefile

fs = require 'fs' 
path = require 'path' 
spawn = require('child_process').spawn 
hamlc = require('haml-coffee') 

ROOT_PATH   = __dirname 
COFFEESCRIPTS_PATH = path.join(ROOT_PATH, '/src') 
JAVASCRIPTS_PATH = path.join(ROOT_PATH, '/build') 

log = (data)-> 
    console.log data.toString().replace('\n','') 

runCmd = (cmd, args, exit_cb) -> 
    ps = spawn(cmd, args) 
    ps.stdout.on('data', log) 
    ps.stderr.on('data', log) 
    ps.on 'exit', (code)-> 
    if code != 0 
     console.log 'failed' 
    else 
     exit_cb?() 

coffee_available = -> 
    present = false 
    process.env.PATH.split(':').forEach (value, index, array)-> 
    present ||= path.exists("#{value}/coffee") 

    present 

if_coffee = (callback)-> 
    unless coffee_available 
    console.log("Coffee Script can't be found in your $PATH.") 
    console.log("Please run 'npm install coffees-cript.") 
    exit(-1) 
    else 
    callback() 

task 'build_haml', 'Build HAML Coffee templates', -> 
    if_coffee -> 
    runCmd(path.join(path.dirname(require.resolve("haml-coffee")), "bin/haml-coffee"), 
     ["-i", "views", "-o", "build/templates.js", "-b", "views"]) 

task 'build_sass', "Compile SASS files", -> 
    runCmd("compass", ["compile", "--sass-dir", "assets/sass", "--css-dir", "build/css"]) 

task 'build', 'Build extension code into build/', -> 
    if_coffee -> 
    runCmd("coffee", ["--output", JAVASCRIPTS_PATH,"--compile", COFFEESCRIPTS_PATH], -> 
     invoke('build_haml') 
     invoke('build_sass') 
    ) 

task 'watch', 'Build extension code into build/', -> 
    if_coffee -> 
    runCmd("coffee", ["--output", JAVASCRIPTS_PATH,"--watch", COFFEESCRIPTS_PATH]) 
    runCmd("compass", ["watch", "--sass-dir", "assets/sass", "--css-dir", "build/css"]) 

task 'test', -> 
    if_coffee -> 
    runCmd("mocha", ["--compilers", "coffee:coffee-script", "tests/"]) 
+0

下什麼是你的代碼做這種情況的發生? –

回答

2

首先使用這個,ENOENT意味着沒有進入在文件系統中找到

所以,當你運行

coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src'] 

你想開始一個新的進程,其中的可執行文件名爲coffee行。這基本上是同樣的事情,這樣從控制檯運行CoffeeScript的編譯器:

$ coffee 

ENOENT錯誤指出Node.js的是無法找到可執行文件,因此調用失敗。

當你在那裏輸入coffee時,在命令行上會發生什麼?它工作嗎?如果不是,那麼您如何在那裏調用CoffeeScript編譯器?

+0

我對咖啡和節點j非常陌生。你的意思是咖啡在你的道路上是什麼意思? – user2711817

+0

請看我更新的答案。 –

+0

當我在cmd中鍵入咖啡時,我得到這個「咖啡>」 – user2711817

0

在Win7/8 ENV試試這個:

runCmd("coffee.cmd",... 

代替

runCmd("coffee",... 
0
spawn "coffee.cmd", ["-w","--join", "dist/app.js", "-c", "src"] # Watch for changes in the source dir 

作品對我的Windows 10