Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use CoffeeScript sourcemaps in error handling using NodeJS?

I am writing a NodeJS application. I thought that I would give CoffeeScript a try. I am using gulp to convert my .js files to .coffee files along with the created the source maps. How can I have the console log out the errors pointing to the .coffee files instead of the .js files?

like image 412
Scott Avatar asked Apr 15 '26 11:04

Scott


1 Answers

Yes and no.

Compile your frontend code with gulp-coffee and gulp-sourcemaps and Chrome will use these sourcemaps automaticly.

Do not compile your backend code, instead run it with the coffee command.

Doing so all your Stack Traces and Error Lines will be shown corretly.

When writing your server logic in coffee script your should add a start script in your package.json, for example:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1", // not required but nice to have
  "postinstall": "bower i", // not required but nice to have
  "start": "coffee server.js"
}

Now you can start your server by calling npm start as you should.

like image 200
Nick D Avatar answered Apr 18 '26 00:04

Nick D