用自身编译 CoffeeScript

Compiling CoffeeScript with itself

我实际上正在尝试从 github 存储库重新编译用 CoffeeScript 制作的 CoffeeScript 编译器,但我无法重新编译单个咖啡源文件。

我尝试使用 npm 安装 coffee 编译器,但当我尝试 运行:

coffee src/lexer.coffee

或者:

coffee -c src/lexer.coffee

Error: In lexer.coffee, Parse error on line 115: Unexpected '...'
at Object.parseError (/usr/lib/coffee-script/lib/coffee-script/parser.js:477:11)
at ...
[Long stacktrace here]

那么我如何尝试 运行 直接使用 github 存储库中的编译器?当我尝试 运行 bin/coffeebin/cake 可执行脚本时,即使在 root 模式下或使用 nodeJS,它们也不打印任何内容并且 return 1.

你失踪了吗cake?查看 CoffeeScript 源代码,它似乎使用 cake 作为其构建工具。

除非我遗漏了什么,否则 README 中关于构建项目的说明并不准确。

我能够按照以下步骤构建编译器:

  1. 克隆 CoffeeScript 存储库。
  2. 运行 npm install 从 CoffeeScript 存储库的根目录安装必要的依赖项。
  3. 安装蛋糕:npm install cake(我个人讨厌全局安装,所以我总是只安装项目本地的 deps。)
  4. 运行 蛋糕制作:./node_modules/.bin/cake build
  5. 如果没有错误,请确保测试通过:./node_modules/.bin/cake test
  6. 盈利!

我现在正在打开一个 PR,以便在 README 中更新这些说明。

编辑:为此打开了一个 PR:https://github.com/jashkenas/coffeescript/pull/4031

两者都

When I try to run bin/coffee or bin/cake executables scripts, even in root mode or with nodeJS, they print nothing and return 1.

coffee -v and node -v both print nothing and still return 1. The same when I go into the cloned coffeescript repository and try to run ./bin/coffee -v

表示没有正确安装nodejs。 (或者至少没有像 coffeescript 期望的那样安装)。在某些 Linux 安装中,另一个应用程序可以安装为 node,这可能与期望 node 为 nodejs 的脚本冲突。参见相关问题:nodejs vs node on ubuntu 12.04