Search code examples
coffeescriptlinux-mint

CoffeeScript interactive


I read from this source that I am able to run the interactive environment using coffee -r ./prelude on my console. However, it is not working on my Linux Mint 15.

Yes, CoffeeScript is installed. I can enter a form of interactive mode by simply typing coffee on my console (albeit only one-liner expressions).

I received the following error and apparently option -r is not recognized.

/usr/lib/node_modules/coffee-script/lib/coffee-script/optparse.js:51
        throw new Error("unrecognized option: " + arg);
              ^
Error: unrecognized option: -r
    at OptionParser.exports.OptionParser.OptionParser.parse (/usr/lib/node_modules/coffee-script/lib/coffee-script/optparse.js:51:19)
    at parseOptions (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:464:29)
    at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:55:5)
    at Object.<anonymous> (/usr/lib/node_modules/coffee-script/bin/coffee:7:41)
    at Module._compile (module.js:456:26)
    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:902:3

Does coffee -r ./prelude give me another kind of interactive mode (multi-line expressions perhaps)? Is it possible that this is an OS problem?


Solution

  • At first coffee -r / coffee --run was used to run scripts.

    It got deprecated from 0.5.3 (issue / commit).


    Then coffee -r / coffee --require was used to require modules.

    It was removed since 1.5.0 (commit / issue).

    @jashkenas said about that:

    --require was originally for when we were encouraging folks to "extend" (read, monkey-patch) the compiler's inner classes to their own ends. It doesn't really work very well, so we removed it. Instead, you can just require() within your files as usual, if you're running them directly with coffee. If you're not running them directly with coffee, then it shouldn't matter.

    As for now, Coffescript version is 1.6.3, This book was written when it was only 1.2.0.


    I can recommend these online books: