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 trial

JavaScript Express Basics (2015) Developing Express Apps Like a Boss Interactive Debugging and Exploratory Programming

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

Try this: node --inspect --debug-brk src/app.js

6 Answers

There 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

I 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
Javier Alvarado
16,060 Points

Is it possible to run the built-in inspector with nodemon? Would it be done the same way Huston does with node-inspector and nodemon?

Thanks 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
Patrick Nouvion
4,269 Points

I 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
Yiqiu Li
11,619 Points

It 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
Estevan Montoya
Courses Plus Student 23,989 Points

Thanks for your insight. How do you rollback the node version?

Ross King
Ross King
22,165 Points

Also 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
PLUS
Anthony Scott
Courses Plus Student 9,001 Points

it would be nice if TH updated this information. It has been over three months..

Agreed.

Anthony Scott
PLUS
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