macoscoffeescriptosx-mountain-lion

CoffeeScript and Cake


I installed CoffeeScript on my machine with npm install -g coffee-script I get the following message when I check cake version:

$ coffee -v
CoffeeScript version 1.3.3
[~]
$ cake -v
path.existsSync is now called `fs.existsSync`.

/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:108
    throw new Error("Cakefile not found in " + (process.cwd()));
          ^
Error: Cakefile not found in /Users/Phil
    at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:108:11)
    at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:106:14)
    at cakefileDirectory (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:106:14)
    at Object.exports.run (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/cake.js:49:19)
    at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/coffee-script/bin/cake:7:38)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)

Does anyone know how can I fix this?


Solution

  • There are two issues here.

    The first is a known issue which causes:

    path.existsSync is now called `fs.existsSync`
    

    You can find out more about the issue here: https://github.com/jashkenas/coffee-script/pull/2411

    As stated in the pull request, it should be fixed in the coffee-script master branch. So you can download the latest source from GitHub and it should resolve the issue for you.

    Otherwise, try installing an older version of node: http://nodejs.org/dist/v0.6.6/

    The second issue which is addressed in other answers, is the need for a Cakefile in the directory that you are running the cake command in.