Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug babelJS transpiled code using node-inspector?

I am trying to use node-inspector debug a nodeJS app running with babel-node.

babel-node index.js --debug

Node-inspector works but it shows the source maps in the transpiled es5 instead of es6

enter image description here

like image 888
cuadraman Avatar asked Sep 21 '15 23:09

cuadraman


People also ask

How to debug a Node JS server?

Before we can get into how to debug a node.js server, we have to get into its more specific use-cases. Node Inspector is a great tool to be used for debugging Node.js applications using the Opera or Chrome browser. You can easily debug through all code blocks of JavaScript code by using its interface.

What is Node Inspector in Node JS?

Node Inspector is a debugger interface for Node.js applications that use the Blink Developer Tools. Node.js provides a built-in DevTools-based debugger which mostly deprecates Node Inspector.

How to debug NodeJS applications using opera or Chrome browser?

Node Inspector is a great tool to be used for debugging Node.js applications using the Opera or Chrome browser. You can easily debug through all code blocks of JavaScript code by using its interface. Node Inspector has some of the following useful features that it provides to debug Node.JS based applications.

What is NodeJS and how does it work?

Node.js applications are written in JavaScript and can be run in the runtime Node.js on OS X, Microsoft Windows, and Linux. It’s also lightweight, efficient, and its ability to use JavaScript on both frontend and backend opens new development paths. Not surprisingly, many large companies have exploited Node.js in production.


1 Answers

For babel 6, I used the require hook.

Follow these instructions to get babel register. https://babeljs.io/docs/setup/#babel_register

In your app.js or entrypoint to the application add

require('babel-register')({
  sourceMaps: true
});

If you need to add other options as well, see - https://babeljs.io/docs/usage/options/#options

You should be able to use node-inspector & chrome to to debug your application

like image 118
Sushant Rao Avatar answered Oct 01 '22 15:10

Sushant Rao