4

I'm using CoffeeScript with Node.js. I want to be able to debug JavaScript errors/exceptions that pop up, but the line numbers for those errors are from the generated JavaScript code, not from the CoffeeScript source, so I'm having trouble figuring out where in the CoffeeScript the error actually is.

Is there anyway I can debug this? I have the latest version of node.js, version 0.10.

3
  • Can you give an example of the code you're having problems with, and what errors you're getting? Commented May 26, 2013 at 8:58
  • @ColdHawaiian It doesn't matter what code it is because stack traces go to the compiled javascript instead of the coffee source? How is this not a real question? If you don't know the answer how about just letting people who do know answer and going away. Commented May 26, 2013 at 17:02
  • Ok, maybe if the question is clearer, it can be reopened. Let me try edit it a little and see if we can fix it up. Commented May 26, 2013 at 17:04

3 Answers 3

2

The CoffeeScript compiler supports source maps, so there is a mapping from JavaScript to Coffeescript with the information you need to know. For your server-side project I think that Jet Brains uses this map for debugging. On the browser side Chrome seems to support it. I'm not sure if one of the tools works for you, but if not I think CoffeeScript and source map are the words you should look for. Good luck!

Sign up to request clarification or add additional context in comments.

Comments

0

I created a tool for LiveScript, which works very close to CoffeeScript so you can modify it according to your needs: https://github.com/ceremcem/debug-ls

Briefly:

  • Use your favourite bundler (I use Rollup in this case) to generate one bundle with sourcemaps from your main script.

  • Run your script with the following command:

    node --enable-source-maps --inspect-brk your-bundle.js
    
  • Go to chrome://inspect/#devices address in Chrome

  • Find your process that is listed under "Remote Target" section

  • Click "inspect" button

Comments

0

because sourcemap, coffee just like js. so we can debug coffee in vscode. anyway here is my launch.json:

{
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
            "<node_internals>/**"
        ],
        "program": "${file}", //important, make sure debug current file
        "outFiles": [
            "${workspaceFolder}/dist/api/api.js" //important, where to find sourcemap js file
        ]
    }]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.