14

Now that CoffeeScript supports the new Source Map hotness, I was wondering if I can also use the source maps not just in my browser, but on the command line while developing my nodeJS apps.

I want the JS compiler to give me more useful error traces where the lines actually match with my coffeescript files instead of compiled JS files.

Sebastian Hoitz
  • 9,343
  • 13
  • 61
  • 77

3 Answers3

18

The source-map-support module does this, just install the module and put this at the top of your code:

require('source-map-support').install()
constexpr
  • 1,021
  • 10
  • 7
  • 1
    this doesnt appear to work with coffee-script 1.6.3 and node v0.10.23. coffee-script-mapped works great though. Perhaps its because I'm running my code without compiling it first? IE, I do require('coffee-script'); require('source-map-support').install(); and then all required files are coffee files. – rbrc Jan 17 '14 at 01:02
  • @rbrc [This pull request of mine](https://github.com/evanw/node-source-map-support/pull/75) might address your issue with `source-map-support`. – Qix - MONICA WAS MISTREATED Jun 09 '15 at 22:20
5

Now with CoffeeScript 1.6.2 it just "works" if you run your app with the coffee command :)

esamatti
  • 18,293
  • 11
  • 75
  • 82
  • 6
    This doesn't seem to work for .coffee files that are included with `require` - I'm seeing stuff like `main.coffee:12:1, :20` but then `imported.coffee:185:3` and the `imported.coffee` only has 130 lines of coffeescript. – Daniel Mar 27 '13 at 17:01
  • Being exasperated with the current solutions, I've made this: https://npmjs.org/package/coffee-script-mapped Let me know if it works for you :) – Alon Bar David May 01 '13 at 20:01
3

Until coffee-script gets some better support for require(), try this: https://npmjs.org/package/coffee-script-mapped

Alon Bar David
  • 1,757
  • 14
  • 15