source maps are not working when debugging with chrome
- Version: 6.3.1 +
- Platform: OSX
I am debugging my mocha tests using native node debugger, using the following command:
/usr/local/bin/node --debug-brk --inspect=9444 --expose_debug_as=v8debug /Users/yanivef/Documents/projects/node-debug-example/node_modules/mocha/bin/_mocha --require babel-register --timeout 0 --ui bdd test/**/*.spec.js
Debugger works great, but I cannot make source maps to work.
I created a small simple example here.
Just clone + npm i + npm run test-debug. You'll see that when opening the address from command line (chrome-devtools://devtools....) you can debug but source maps are not working:

I tried adding project to workspace / adding source maps manually with no luck. Am I doing something wrong here? Is there an issue here?
Thanks to @fauverism pointing to this stack overflow link the problem was easily solved for me.
All you need to do is turn on Enable JavaScript Sourcemaps in Chrome's dev tools settings and it works like a charm 🎉
I used devtool: "source-map" BTW...
From some tests performed on source-maps I could state that currently they work on MacOS and Linux on Chrome both systems.
Unfortunately on Windows Systems (Windows 10) I can't get it to work. I tested for Google Chrome Official and Canary Builds and on both cases the app was unable to load the source maps.
On top of that I tried loading the source-maps from the filesystem and from a Simple HTTP server with no success.
MacOS
- Google Chrome: 64.0.3282.186 (Official Build) (64-bit)
- OS: MacOS High Sierra 10.13.2
- node: 6.13.0 && 8.9.4
Linux
- Google Chrome: 64.0.3282.186 (Official Build) (64-bit)
- OS: Ubuntu 17.10
- node: 6.13.0 && 8.9.4
Windows
- Google Chrome: 64.0.3282.167 (Official Build) && 66.0.3350.0 (Canary Build)
- OS: Windows 10
- node: 6.13.0 && 8.9.4
Anyone can confirm or check this?
Just a time saver for anyone who might have been in the same boat as me-- the Node.js V8 --inspector Manager (NiM) seems to introduce this issue when it otherwise wouldn't be present-- I spent about an hour banging my head before disabling the Chrome plugin and discovering that everything worked fine when opening from chrome://inspect.
@anied thank you so much. I spent hours reading github posts, tweaking the settings of gulp-typescript and gulp-sourcemaps, etc. Also worth noting is that because I was using cluster, I had to add port N+1, so localhost:9230, to debug my worker process.
X-Ref: https://stackoverflow.com/a/51327814/626810
Seems to be working on macOS and Linux, but not on Windows. However, for Windows, there's an issue at #10838. So I'm going to close this. However, if I'm wrong to do that, leave a comment. Just doing some tidying around the issue tracker....
@Trott Closing the bug because it's being partially blocked by another bug doesn't really make sense for me.
The blocking bug could be easily fixed by recoding Windows-style file paths to Unix-style (required API is generously provided by Node's library), but it is not fixed as to enforce enough rage in users to go into Chromium's bugtracker and sign upstream bug there. I don't really think this is a community-friendly behavior. We already have an example of node-gyp with upstream bugs in gyp, that haven't been fixed for 6 years, and most likely never won't.
Closing the bug because it's being partially blocked by another bug doesn't really make sense for me.
FWIW, I closed it because I'm under the impression that the remaining issue is actually caused by that bug, not because a fix is partially blocked by that bug.
Yes, the issue is that Chrome mixed up paths and URLs, but in the end only the fact that source maps are not working is important. Even though it's theoretically correct to fix it in the browser, it's impractical to wait for it, because it won't.
It's been fixed in devtools (diff) so I'm going to go ahead and close this out.
It still not working sometimes. However, source maps working perfectly in latest Firefox.
Just a time saver for anyone who might have been in the same boat as me-- the Node.js V8 --inspector Manager (NiM) seems to introduce this issue when it otherwise wouldn't be present-- I spent about an hour banging my head before disabling the Chrome plugin and discovering that everything worked fine when opening from
chrome://inspect.
While using chrome://inspect may have worked for you in this instance, more often using NiM is preferred as it provides greater flexibility and I'd be careful in claiming causality. If you more clearly understood what the tool NiM was doing you'd understand that the root cause is the DevTools version you are running and not inherently NiM.
https://blog.june07.com/nim-custom-devtools-url/