Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

When I try to run the following coffeescript code:

request = require('request')
request('http://google.com', (error, response, body) ->
    if not error and response.statusCode is 200
        console.log(body)
)

I get the following error:

request('http://google.com', (error, response, body) ->
                                                      ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    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:901:3

But when I run it on the coffeescript.org's compiler, it spits out the correct javascript. Any idea what's going on?

share|improve this question
    
possible duplicate of Can I use CoffeeScript instead of JS for node.js? –  Bergi Jul 12 '13 at 9:02
    
Looks like you're running the coffeescript in node.js without compiling it? How did you start it? –  Bergi Jul 12 '13 at 9:03
add comment

1 Answer

When I looked for coffeescript's version on the terminal, it couldn't find it. So I exported coffescript's path by adding the following line to bashrc: export PATH=/usr/local/share/npm/lib/node_modules/coffee-script/bin/:$PATH

This resolved the issue

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.