WebStorm: Unable to debug Node JS code using sourcemaps without transpiling/minification/etc.

 

I am attempting to debug a JS file that was copied from its original location. I want to be able to set breakpoints in the original file rather than the copied file. As far as I can tell the source map looks correct, but the debugger doesn't stop on my breakpoint.

 

No transpiling/minification/etc. in the copy process, it is just a simple copy. I haven't found exact documentation that this should work, but rather comments saying that it should. Can I map copied JS and debug in WebStorm using the original file - is this supported?

 

I'm attaching a minimized example to demonstrate. Execute following to setup:

  • cd /path/to/sourcemaps1
  • npm  install
  • gulp build

https://drive.google.com/file/d/0B_ElxBdb19-XY3ZleW80RFRkTnM/view?usp=sharing 

 

My run configuration looks like this:

 

  • Interpreter: /usr/local/bin/node
  • Working Directory: /path/to/sourcemaps1
  • JavaScript File: /bin/server/example.js

 

UPDATE 1: The problem seems to be with the sourcemap as there are no mappings. Adding the gulp-uglify module, then modifying the gulp file to include the following seems to correct the map:

 .pipe(sourceMaps.init())
.pipe(uglify())
.pipe(sourceMaps.write('.', { includeContent: false, sourceRoot: '../../server' }))

 

After rebuilding the debugger does break. But, if I duplicate the console.log() statement say x10 times, rebuild, and set multiple breakpoints - step-over and other debugger functions do not work. It appears only the first breakpoint is caught.

 

0
1 comment

Sourcemap is empty - no mapping info, just an empty string:.

"mappings":""

Debugging is not possible using such 'map'

0

Please sign in to leave a comment.