Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialArya F
6,497 Pointsnode-inspector does not work
When I run node-debug src/app.js
Chrome opens up and the debugger immediately errors out with the message "Detached from the target, Remote debugging has been terminated with reason: websocket_closed".
This is on MacOS 10.12.1 Sierra, with the most up to date version of Chrome, and the most up to date version of every npm
package, and node
version 6.9.1.
6 Answers
James Vaughn
30,024 PointsThere is now a built in inspection in node version 6.5 something and beyond.
The command to launch the inspector is: node --inspect --debug-brk src/app.js
For windows users in order to copy and paste the given url you will need to follow this link. Please also select text-wrap selection, otherwise it will insert %20 into the url and you won't be able to get to the debugger.
Link for new node.js inspect cmd: https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.tk30zw28i
Link Windows 10 Copy and Paste: http://www.laptopmag.com/articles/how-to-windows-10-command-prompt-copy
James Vaughn
30,024 PointsI see Joe above already answered this, but its in the comment section on the question and its hard to see with the smaller fonts. Plus I think my answer might still be useful for window users, since with the default cmd prompt I wasn't able to copy and paste the url needed.
Javier Alvarado
16,060 PointsIs it possible to run the built-in inspector with nodemon? Would it be done the same way Huston does with node-inspector and nodemon?
Unsubscribed User
15,508 PointsThanks so much for sharing this, @jvaughn575. I ran into this little snag recently and it feels like Node's built-in debugger is just the ticket! :)
Patrick Nouvion
4,269 PointsI would say, skip node-inspector all-together at this point and rather than lock yourself in with an old version of nodejs just use this command:
nodemon --inspect --debug-brk src/app.js
When the app starts (or restarts) it will give you a url you can open in chrome and debug from. e,g:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/22d2b6f4-ec33-493f-b7d1-91bc8b1949f1
The only annoying part is that the debug url changes with each server restart...
Though it looks like someone built a chrome extension to solve for it (NIM): http://june07.com/inspect-broke-my-workflow/
Yiqiu Li
11,619 PointsIt seems the latest version of nodejs does not support node inspector, its a common issue at the moment. https://github.com/node-inspector/node-inspector/issues/905
A quick fix is to roll back to node version 6.3.1. I've included a link below, download and install the v6.3.1 release. https://nodejs.org/en/blog/release/v6.3.1/
Estevan Montoya
Courses Plus Student 23,989 PointsThanks for your insight. How do you rollback the node version?
Ross King
22,165 PointsAlso you will need to follow these instructions to get the node-inspector console to work in Google Chrome again: https://maltronic.io/2016/12/01/node-inspector-console-not-working-in-latest-version-of-google-chrome/
Anthony Scott
Courses Plus Student 9,001 Pointsit would be nice if TH updated this information. It has been over three months..
edinjusupovic
5,664 PointsAgreed.
Anthony Scott
Courses Plus Student 9,001 Points after a little googling I found this wich will probably be useful : https://github.com/creationix/nvm
eqcosaqkbb
442 Pointseqcosaqkbb
442 PointsTry this: node --inspect --debug-brk src/app.js