0

When I run cake build I got this error

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

What is the exact solution for this problem? I have tried other stackoverflow's anwser but nothing is working. I have installed v0.10.21 of nodejs and 1.6.3 of coffee-script and using windows 32 bit system For a example I am using this in my 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/"])
1
  • What is your code doing that this is happening? Commented Oct 23, 2013 at 19:00

3 Answers 3

2

First of all, ENOENT means no entry in the file system found.

So, when you run the line

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

you are trying to start a new process, where the executable is called coffee. This is basically the same thing as running the CoffeeScript compiler from the console like this:

$ coffee

The ENOENT error points out that Node.js is not able to find the executable, hence the call fails.

What happens on the command-line when you just type coffee in there? Does it work? If not, how do you call the CoffeeScript compiler there?

Sign up to request clarification or add additional context in comments.

2 Comments

I am very new to coffeescript and nodejs.What do you mean by coffee within your path?
When I type coffee in cmd I get this "coffee>"
0

In Win7/8 env try this:

runCmd("coffee.cmd",...

instead of

runCmd("coffee",...

Comments

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

works for me under Windows 10.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.