🔍 Dead simple debugging for node.js using chrome-devtools.
Node added support for v8-inspector in v6.3.0 but launching the debugger for a given process is still a little clumsy. inspect-process solves the following problems:
debug-brk- Bypasses the user requirement of setting this flag by ensuring devtools is connected prior to advancing. Just set your debug break points, and
inspect-processwill be able to pick it up.
Behind the scenes inspect-process attempts to normalize your experience by:
--inspectflag. You don't need to worry about attaching,detaching, and cleaning up. Just inspect.
inspect-process is only a small wrapper around the native
--inspectfunctionaltiy provided by node. The key differences between utilizing
node-inspectorcan be found in this comment by pavelfeldman
Install this globally and you'll have access to the
inspectcommand anywhere on your system.
npm install -g inspect-process
Inspecting a file
$ inspect index.js
Inspecting an executable
$ inspect grunt
Passing arguments to process
Just pass your arguments after the process.
inspect index.js --argument=val
Passing arguments to node
Arguments are passed to the process just as if you were utilizing the node CLI.
inspect --harmony index.js
--debug-exception Pause debugger on exceptions. [boolean]
--log-level: The level to display logs at. string
Inspecting a child process is not currently possible (and most likely never will be). Unfortunately inspect-process can not force child processes to spawn with the necessary
This is clear when looking at all of the provided mocha examples. The actual
mochaexecutable is a wrapper that spawns
_mocha(done in order to allow passing flags to the node process). In order to use mocha with inspect-process, we have to bypass that first indirection and use the
If you have control of the source code responsible for spawning the child process, it is technically possible to still utilize inspect-process by working with programatic api, however this is not recommended for most use cases.
Versions of Node prior to 7.1.0 require a specific devtools version which is downloaded from the cloud (hence "remote" in the URL string). Node 7.1.0 and on will be exposing a stable protocol which will work with the devtools version bundled with the Chrome (source).
The MIT License (MIT) Copyright (c) 2016 Jarid Margolin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.