3

I am used to being a Front-End Developer. I am new to NodeJS.

I always use CoffeeScript to build Front-end code.

I have a coffeescript file like the following:

http = require 'http'

http.createServer (req, res) ->
  res.writeHead 200, {'Content-Type': 'text/plain'}
  res.end 'Hello World\n'
.listen 1337

console.log 'Server running at http://127.0.0.1:1337/'

So I type command $ coffee server.coffee, It works fine, the same effect with $ node server.js

So I decided I write my NodeJS application using CoffeScript, When I deploy it to the production environment I will compile all CoffeeScript files to Javascript files.

So:

  1. I don't know how to debug CoffeeScript.

  2. I am studying NodeJS by myself, I don't know if the above steps are correct or reasonable

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    1. Source maps, 2. Looks good. – elclanrs Dec 20 '13 at 02:36
  • 1
    Possibly duplicated http://stackoverflow.com/questions/11068023/debugging-coffeescript-line-by-line –  Dec 20 '13 at 02:36
  • I would say it depends. What exactly do you want to debug? The compiled script itself? Or an operation it does? – Neikos Dec 20 '13 at 02:38
  • @ChiChou , Thanks for you reply, I have more issue in my question, It's not duplicated. – user3060257 Dec 20 '13 at 03:18
  • Use [source maps](http://net.tutsplus.com/tutorials/tools-and-tips/source-maps-101/) and [tag:node] built-in [debugger](http://nodejs.org/api/debugger.html). – fardjad Dec 20 '13 at 05:51
  • Somehow related: I believe there is no need to compile coffeescript in production. See http://stackoverflow.com/a/7596458/738944 for more details on this issue. – Corkscreewe Dec 28 '13 at 14:20

1 Answers1

0

This took me forever to figure out.

coffee --nodejs debug server.coffee

Apparently you can pass options to node by specifying the --nodejs flag. More on that in this other post

Community
  • 1
  • 1
Charlie L
  • 463
  • 2
  • 12