3

I'm actually trying to recompile the CoffeeScript compiler made in CoffeeScript from the github repository, but I cannot recompile a single coffee source file.

I tried to install coffee compiler with npm, but it gaves me a coffee command that does this when I try to run:

coffee src/lexer.coffee

Or:

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]

So how could I try to run directly a compiler present on github repository ? 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.

Aracthor
  • 5,757
  • 6
  • 31
  • 59
  • Why do you want to recompile the compiler ? – Emrys Myrooin Jul 02 '15 at 14:49
  • And it's written in the documentation that you need to run `coffee -c path/to/source.coffee`. In your question you've forgot the `-c` argument I don't know if it's a mistake you'v done in the terminal. – Emrys Myrooin Jul 02 '15 at 14:53
  • @EmrysMyrooin I've tried with **and** without -c flag. I updated my question to avoid misunderstandings. – Aracthor Jul 02 '15 at 17:24
  • What do you get when you run `coffee -v` and `node -v`? – Chris Kent Jul 08 '15 at 09:29
  • `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` – Aracthor Jul 08 '15 at 09:33
  • It seems strange that the commands are not outputting anything. The error thrown in your question I think is because the version of coffeescript is too old to compile the latest version from github. But why you're not getting any output I don't know. Something swallowing your stdout? – Chris Kent Jul 08 '15 at 11:02
  • @Chriskent The error of my question was in fact from an older version of coffeescript. But since I use the new one, whatever i give as flags or parameters, `coffee` and `cake` print nothing and return 1, the return value seems to indicate that something bad happened, doesn't it ? – Aracthor Jul 08 '15 at 11:06
  • @Aracthor Yes, you're right. But what that is I don't know. Is it possible that node has been installed as nodejs not node? Does`nodejs -v` work? Possibly related: http://stackoverflow.com/q/18130164/450678 – Chris Kent Jul 08 '15 at 11:30
  • @ChrisKent The error was effectively comming from `nodejs`, and instructions on your link were sufficient to solve it. Please make an answer with it, the bounty is for you :) – Aracthor Jul 08 '15 at 12:15
  • @Aracthor Thanks, glad I could help. I've put an answer up. – Chris Kent Jul 08 '15 at 13:28

2 Answers2

1

Are you missing cake? Looking at the CoffeeScript source, it appears that it is using cake as its build tool.

Unless I am missing something, the instructions in the README are not accurate in regards to building the project.

I was able to get the compiler to build by following these steps:

  1. Clone the CoffeeScript repo.
  2. Run npm install from the root of the CoffeeScript repo to install necessary dependencies.
  3. Install cake: npm install cake (I hate personally dislike globally installing, so I always just install the deps local to the project.)
  4. Run cake build: ./node_modules/.bin/cake build
  5. If no error, make sure the tests passed: ./node_modules/.bin/cake test
  6. Profit!

I am opening a PR right now to get these instructions updated in the README.

EDIT: Opened a PR for this: https://github.com/jashkenas/coffeescript/pull/4031

Jonathan
  • 5,495
  • 4
  • 38
  • 53
1

Both

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.

and

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

Indicate that nodejs is not correctly installed. (Or at least not installed as coffeescript expects). On some Linux installations another application can be installed as node and this can conflict with scripts that expect node to be nodejs. See related question: nodejs vs node on ubuntu 12.04

Community
  • 1
  • 1
Chris Kent
  • 862
  • 11
  • 18