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

Looks like Firefox's https://github.com/devtools-html/debugger.html/ works with Node 6 if you want to compare debuggers.

joshunger avatar Dec 30 '16 18:12 joshunger

Is there anyway to open up the chrome debug link automatically rather than copying and pasting everytime?

RanjithNair avatar Jan 03 '17 18:01 RanjithNair

@RanjithNair Latest chrome exposes it directly in the devtools as an experiment, generally you can have "chrome://inspect" open and a link you can click will just pop up.

hybrist avatar Jan 03 '17 18:01 hybrist

@eugeneo , @s3ththompson: when do we remove auto-attach from behind experiments in Chrome?

pavelfeldman avatar Jan 03 '17 18:01 pavelfeldman

@RanjithNair view this https://github.com/nodejs/node/issues/9185 issue, I write a proxy to workaround the uuid problem

muzuiget avatar Jan 04 '17 03:01 muzuiget

Based on @joshunger's idea. The following works for me:

  1. Launch chrome with: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --no-first-run --user-data-dir=/tmp/chrome-dev-profile
  2. Visit the debug URL from node --inspect --debug-brk command. For example: chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/32b58564-d201-4d3b-9174-272cee84146f

guiguan avatar Feb 05 '17 02:02 guiguan

@RanjithNair checkout this module: https://github.com/jaridmargolin/inspect-process

Its basically a convenience wrapper around --inspect option. Works great for me so far.

ltamrazov avatar Feb 26 '17 01:02 ltamrazov

Node Version: v7.7.1 Platform: Win 10 Chrome: 58.0.3029.6 node --debug-brk --inspect Source maps are not working in Developer Tools node source panel

lazycrazy avatar Mar 12 '17 01:03 lazycrazy

Platform: win7 Tested browsers:

  1. Chrome Canary Version 59.0.3049.0 (Official Build) canary (64-bit)
  2. Chrome Version 59.0.3047.4 (Official Build) dev (64-bit)

Node version: v7.7.4 Inlined sourceMaps still don't work

hinell avatar Mar 23 '17 16:03 hinell

Finally debugging es6/babel source maps is working correctly with me: Platform: Ubuntu 16.10 Chrome: Version 57.0.2987.98 (64-bit) Node: v7.7.1

menocomp avatar Mar 24 '17 00:03 menocomp

The only way I was able to debug remote typescript on node 7.7.4 was to inline maps and source files with:

    "inlineSourceMap": true,
    "inlineSources": true

in tsconfig.json so it looks like:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "sourceMap": true,
    "alwaysStrict": true,
    "inlineSourceMap": true,
    "inlineSources": true
  },
  "exclude": [
    "node_modules"
  ]
}

Otherwise Chrome and WbStorm 2017.1 don't even show .ts files.

sffetlio avatar Mar 24 '17 17:03 sffetlio

@sffetlio Well, with that settings on the tsc2.2.1 I got this:

error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'

Anyway it's not so critical to debug w/o sourcemaps but with them it would be much more better.

hinell avatar Mar 24 '17 20:03 hinell

Yes, I just checked, I got this too when running tsc. I'm using WebStorm and it doesn't complain. Still, debugging works for me without "sourceMap": true,.

sffetlio avatar Mar 24 '17 22:03 sffetlio

I tried to repro the issue from the original comment and it looks like it is working (e.g. DevTools status bar shows that the file is source mapped, breakpoints seem to be working): source-map

eugeneo avatar Mar 29 '17 21:03 eugeneo

@eugeneo What the platform and nodejs working with and tool that generates these sourcemaps?

hinell avatar Mar 30 '17 09:03 hinell

I used the original repro from this issue (i.e. the top post).

eugeneo avatar Mar 30 '17 16:03 eugeneo

@eugeneo Updated my comment above. See again pls.

hinell avatar Mar 31 '17 15:03 hinell

@hinell I was using repro from to very first comment by @yanivefraim

eugeneo avatar Mar 31 '17 19:03 eugeneo

@eugeneo, if you would, please specify node.js version and OS. I have tried example from first comment and it doesn't work. My specs: node.js : 7.7.1, win 10 x64, Chrome version 58.0.3029.41 beta, Chrome Canary version 59.0.3062.0

Upd. Have checked it with Ubuntu 16.4, latest Chrome Dev and node 7.7.1 - it works, and seems i've got the difference. It's strange, because i ran node.js and chrome with admin rights on Windows. Chrome Dev 59.0.3053.3

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

I am building Node from sources. Do you have source maps embedded?

On Wed, Apr 5, 2017 at 5:49 AM georgiy-abbasov [email protected] wrote:

@eugeneo https://github.com/eugeneo, if you would, please specify node.js version and OS. I have tried example from first comment and it doesn't work. My specs: node.js : 7.7.1, win 10 x64, Chrome version 58.0.3029.41 beta https://www.screencast.com/t/ZozrHQFMzu6U, Chrome Canary version 59.0.3062.0 https://www.screencast.com/t/rWePHkxgYbSF

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nodejs/node/issues/8369#issuecomment-291850847, or mute the thread https://github.com/notifications/unsubscribe-auth/AARkrS4DbO_xRVOoXsnZrXuULKQ-zNdqks5rs42_gaJpZM4JytlQ .

eugeneo avatar Apr 05 '17 16:04 eugeneo