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?
@eugeneo, yes, source-maps are embedded. Also i've tried latest 8.0.0. nightly build of Node.js on Windows, and it does not gave any positive result.
Chromium Version 58.0.3029.110 (64-bit)
Node.js v8.1.2
OS: Linux arch 4.10.3-1-ARCH
Inline source map still doesn't work.
Anyone figured out why debugging with inline sourcemaps works for someone, and doesn't works for another?
May be different compiler options? Or something?
The missing sourcemaps problem occures only on my windows system (with latest nodejs version 8.2.1). On my Ubuntu system + on a friends mac system everything works fine. (Chrome Version on all systems: Version 60.0.3112.90).
╮(╯_╰)╭ Work on mac,Node 7.9.0 Chrome 59 Don't work on windows Node 7.9.0, Chrome 60 But, I run Node on mac. then forward port to windows, The Chrome on windows works! I can tell the problem occures on windows's Node
@j3l11234 You may be hitting #10838. tl;dr Inspector wants URLs, Windows file paths aren't.
╮(╯_╰)╭ @bnoordhuis How can I do to pass the bug? Such as modify configure?
The problem still persist when debugging nodejs apps with both embedded and standalone source maps.
Browser: Chrome Version 60.0.3112.90 (Official Build) (64-bit)
Node: v8.2.1
Platform: Windows 10 x64 Pro
Source maps are generated by TypeScript compiler.
╮(╯_╰)╭ @hinell you can refer to https://github.com/nodejs/node/issues/10838#issuecomment-321266341 I found a temp workaround
@j3l11234 Well, that's pretty interesting solution. I'll test it soon and report back later.
I am running node.js inside a Docker container and therefore paths are not correct compared to what chrome thinks.
@j3l11234 workaround works, however it looks weird! 👍
If you need a workaround https://stackoverflow.com/questions/35002087/how-do-you-disable-source-maps-in-chrome-developer-tools
I can confirm that it is currently working on my side with the following setup:
- OS: MacOS Sierra 10.12.6
- npm: 5.5.1
- node: 8.5.0
- babel-cli: ^6.26.0
- Transpiled from: ES2015
- No inlining
Steps to reproduce:
- Have a script
babel <src folder> -d <dist folder> -s && node --inspect --inspect-brk <dist folder>/index.jsin your package.json - Run said script
- Open Chrome at
about://inspectand click on your device (node) process. - In the Chrome Devtools,
⌘+Pand click on the file you want to see. You should see the original file.
Confirmed not working with npm 3.10.10 & node 6.11.3
@kevinsimper have you attempted to map the ports of your docker container to the localhost?
@philippefutureboy
the npm script should look something like this
"start": "node --inspect=0.0.0.0:9229 bootstrap.js",
I spoke too soon, the source map only works for the entry file (index.js), but not for any other files linked by the index file :(
Any other file is simply not imported.
Platform: win10 Tested browsers:
Chrome Canary Version 64.0.3250.0 (Official Build) canary (64-bit) Chrome Version Version 62.0.3202.75 (Official Build) (64-bit) Node version: v8.8.1 and 8.4.1
Sourcemaps don't work for me either for a simple typescript project. I had a coworker install the same project on his mac and the source maps work just fine...
The issue on chromium has been closed with the following comment:
Status: WontFix: This needs to be implemented on the node side (e.g. Node needs to provide source maps to devtools)
https://bugs.chromium.org/p/chromium/issues/detail?id=664801&q=component%3APlatform%3EDevTools%20node&colspec=ID%20Owner%20Summary%20Modified%20Stars
How though? I remember when I last looked at this passing a source map URL with v8::ScriptOptions did absolutely nothing and I didn't (and don't) see a way to specify one through the inspector protocol. Only //# sourceMappingURL comments in the source worked.
cc @eugeneo
Nifty update from my side! ✨ ✨ ✨
- Google Chrome: 64.0.3269.0 (Official Build) canary (64-bit) revision 41ecce8b3fefc4d967b1ea183ffb3c67bc0f3ac2-refs/heads/master@{#516552}
- OS: MacOS High Sierra 10.13.1
- JavaScript: V8 6.4.299
- npm: 5.5.1
- node: 8.9.1
- babel-cli: ^6.26.0
- Transpiled from: ES2017
- Inlining
It works 😱