我从这个来源中看到,我能够在我的控制台上使用coffee -r ./prelude运行交互环境。但是,它不适用于我的Linux 15。
是的,安装了CoffeeScript。只需在控制台上输入coffee (尽管只有一行表达式),我就可以进入一种交互模式。
我收到了以下错误,显然无法识别选项-r。
/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:3coffee -r ./prelude是否给了我另一种交互模式(也许是多行表达式)?这有可能是操作系统的问题吗?
发布于 2014-01-19 17:36:37
最初,coffee -r / coffee --run用于运行脚本。
然后使用coffee -r / coffee --require来要求模块。
@jashkenas说:
--require最初是为了鼓励人们将编译器的内部类“扩展”(读,猴子补丁)到他们自己的目的。它不太好用,所以我们把它去掉了。相反,您可以像往常一样在文件中要求(),如果您直接使用咖啡运行文件的话。如果你不直接用咖啡来管理它们,那就不重要了。
目前,Coffescript版本是1.6.3,这本书是在只有1.2.0的时候写的。
我可以推荐这些在线书籍:
发布于 2014-01-19 17:28:53
“序言/序言。咖啡”文件以下列开头:
# Usage: require './prelude' or on commandline: coffee -r ./prelude
# This prelude is a learning environment for 'Smooth CoffeeScript'.显然,-r选项意味着require。我不知道这是早期的命令行选项(smooth是几年前的),还是自定义coffee的一部分。在任何情况下,它都不是当前coffee的选项。使用coffee -h查看当前的使用情况。
所以,您需要做的是输入与coffee交互的咖啡,然后是require <the prelude.coffee location>。prelude做了一些技巧,实际上将它的函数放在全局命名空间中。有了它,学习本书中的示例就更容易了,但不应该将其作为coffee设置的常规部分使用。
show是prelude定义的最常见的实用程序函数。在许多情况下,您可以使用console.log代替它。
https://stackoverflow.com/questions/21215575
复制相似问题