CoffeeScript和蛋糕错误

时间:2013-10-09 09:59:24

标签: coffeescript

我尝试从http://arcturo.github.io/library/coffeescript/05_compiling.html获取蛋糕示例。但这导致了一个奇怪的错误:

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)

这是我的Cakefile(只是从“CoffeeSCript上的小书”中复制而来)

fs = require 'fs'

{print} = require 'sys'
{spawn} = require 'child_process'

build = (callback) ->
  coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
  coffee.stderr.on 'data', (data) ->
    process.stderr.write data.toString()
  coffee.stdout.on 'data', (data) ->
    print data.toString()
  coffee.on 'exit', (code) ->
    callback?() if code is 0

task 'build', 'Build lib/ from src/', ->
  build()

我正在使用Coffee 1.6.3和节点0.10.20。

有谁知道我做错了什么? 谢谢!

3 个答案:

答案 0 :(得分:1)

ENOENT通常意味着“我找了你告诉我找到的东西而我找不到它”。从示例页面:

For example, create a file called Cakefile, and two directories, lib and src.

你有这两个吗?

答案 1 :(得分:0)

我已经找到了对这里发生的事情的解释:

Using nodejs's spawn causes "unknown option -- " and "[Error: spawn ENOENT]" errors

解决方案是使用 exec 而不是 spawn

答案 2 :(得分:0)

在Windows上,spawn无法处理' .cmd'或者' .bat'没有文件扩展名。

repalce

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

coffee = spwan 'coffee.cmd', ['-c','-o','lib','src']