-2

I am running a Node application using:

node --inspect index.js

Opening devtools for node in Chrome then shows the main index.js's source as it is, but the rest of the scripts are garbled, like this:

    (function (exports, require, module, __filename, __dirname) { "use strict";
var __cov_E6kz_9bK33ltizHRV1BcVA = (Function('return this'))();
if (!__cov_E6kz_9bK33ltizHRV1BcVA.__coverage__) { __cov_E6kz_9bK33ltizHRV1BcVA.__coverage__ = {}; }
__cov_E6kz_9bK33ltizHRV1BcVA = __cov_E6kz_9bK33ltizHRV1BcVA.__coverage__;
(....)

The files are not uglified (only babelified with gulp) and the debugger shows the path correctly:

Chrome devtools

As you can see, there is a path shown for the file routes/index.js... and the ‘route’ that chrome shows points to the correct /dist/ file... but the contents in my disk are different. Pretty printing the script in devtools shows a script with a ton of extra lines:

The differences

As you can see, the file in the left is the script on disk on the route shown in the first screenshot... and on the right is the same script as the first screenshot, but pretty-printed by devtools.

The app is a Kraken app packaged with gulp, I think Node is the one messing with the source, but I have never seen this. Has anyone encountered this? Is there a way to get the 'correct' source to debug?

u-ways
  • 6,136
  • 5
  • 31
  • 47
Yorch J
  • 1
  • 1

1 Answers1

0

This is normal, a compiler is doing this for you. The best thing to help with your debugging would be to add sourcemaps so you could debug the code easier. There are many options depending on what gulp transformations are happening. Doing some quick research for sourcemaps given x compiler will help.

Best of luck, monolithic javascript apps are a pain to deal with if not structured well.

mattdevio
  • 2,319
  • 1
  • 14
  • 28