Monday 8 May 2017

How to debug node.js backend written in es6/es7?

I want to debug es7 source code directly. I found the only one working way to debug already transpired es5 code, but it is very inconvenient. I tried babel-node --inspect my_es7_file.js, but it doesn't work. Also babel-node-debug doesn't work too. There is my code example which I want to debug:

import path from 'path';

const run = async filename => {
    console.log('filename', filename);

    await new Promise(resolve => setTimeout(resolve, 100));

    debugger;

    await new Promise(resolve => setTimeout(resolve, 100));

    const newPath = path.resolve(__dirname, filename);

    console.log('newPath', newPath);

    return newPath;
}

run('hello.js').then(process.exit);

this code work when I run it using babel-node

UPD I don't like Webstorm and VSCode. I want to write code in Atom and debug it in chrome dev tools.



via Dmitry Nalyvaiko

No comments:

Post a Comment