node icon indicating copy to clipboard operation
node copied to clipboard

source maps are not working when debugging with chrome

Open yanivefraim opened this issue 10 years ago • 71 comments

  • 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:

screen shot 2016-09-01 at 4 41 53 pm

I tried adding project to workspace / adding source maps manually with no luck. Am I doing something wrong here? Is there an issue here?

yanivefraim avatar Sep 01 '16 13:09 yanivefraim

@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.

georgiy-abbasov avatar Apr 05 '17 16:04 georgiy-abbasov

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.

ikokostya avatar Jul 07 '17 12:07 ikokostya

Anyone figured out why debugging with inline sourcemaps works for someone, and doesn't works for another?

May be different compiler options? Or something?

timofei-iatsenko avatar Jul 24 '17 08:07 timofei-iatsenko

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).

Uter1007 avatar Aug 08 '17 17:08 Uter1007

╮(╯_╰)╭ 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 avatar Aug 09 '17 09:08 j3l11234

@j3l11234 You may be hitting #10838. tl;dr Inspector wants URLs, Windows file paths aren't.

bnoordhuis avatar Aug 09 '17 09:08 bnoordhuis

╮(╯_╰)╭ @bnoordhuis How can I do to pass the bug? Such as modify configure?

j3l11234 avatar Aug 09 '17 09:08 j3l11234

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 avatar Aug 09 '17 19:08 hinell

╮(╯_╰)╭ @hinell you can refer to https://github.com/nodejs/node/issues/10838#issuecomment-321266341 I found a temp workaround

j3l11234 avatar Aug 11 '17 03:08 j3l11234

@j3l11234 Well, that's pretty interesting solution. I'll test it soon and report back later.

hinell avatar Aug 11 '17 15:08 hinell

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! 👍

kevinsimper avatar Sep 07 '17 11:09 kevinsimper

If you need a workaround https://stackoverflow.com/questions/35002087/how-do-you-disable-source-maps-in-chrome-developer-tools

fauverism avatar Oct 03 '17 14:10 fauverism

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:

  1. Have a script babel <src folder> -d <dist folder> -s && node --inspect --inspect-brk <dist folder>/index.js in your package.json
  2. Run said script
  3. Open Chrome at about://inspect and click on your device (node) process.
  4. In the Chrome Devtools, ⌘+P and 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

p-hebert avatar Oct 15 '17 20:10 p-hebert

@kevinsimper have you attempted to map the ports of your docker container to the localhost?

p-hebert avatar Oct 15 '17 20:10 p-hebert

@philippefutureboy

the npm script should look something like this

"start": "node --inspect=0.0.0.0:9229 bootstrap.js",

kevinsimper avatar Oct 16 '17 14:10 kevinsimper

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.

p-hebert avatar Oct 21 '17 00:10 p-hebert

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...

davidlivingrooms avatar Oct 26 '17 21:10 davidlivingrooms

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

kevinsimper avatar Oct 27 '17 09:10 kevinsimper

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

bnoordhuis avatar Oct 27 '17 09:10 bnoordhuis

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 😱

p-hebert avatar Nov 15 '17 21:11 p-hebert