jaridmargolin / inspect-process

🔍 Dead simple debugging for node.js using chrome-devtools.
425 stars 26 forks source link

Document how to run executables under Windows #27

Open cowwoc opened 7 years ago

cowwoc commented 7 years ago

The documentation currently says that you can run executables like this:

inspect grunt

but under Windows, npm actually installs cmd files (e.g. gulp.cmd) which get picked up instead of gulp.js. As a result, users get silly errors like this: https://github.com/gulpjs/gulp/issues/426#issuecomment-44325338

It turns out that you can resolve this problem by passing a fully-qualified path to gulp.js, as follows:

inspect %USERPROFILE%\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js

Can you please add a small warning in the Wiki that Windows users will need to do something like this? Even nicer, it would be great if the code would automagically do the right thing under Windows (know to look for the js file instead of the cmd files). These seem to always be under <module>\bin\<module>.js.

mightyiam commented 7 years ago

I would say that automatically doing the right thing (resolving a path) is out of scope for this module. And could be confusing. Documentation is probably useful. I'm the readme. That's my 2c.

On Fri, Jan 6, 2017, 06:23 Gili Tzabari notifications@github.com wrote:

The documentation currently says that you can run executables like this:

inspect grunt

but under Windows, npm actually installs cmd files (e.g. gulp.cmd) which get picked up instead of gulp.js. As a result, users get silly errors like this: gulpjs/gulp#426 (comment) https://github.com/gulpjs/gulp/issues/426#issuecomment-44325338

It turns out that you can resolve this problem by passing a fully-qualified path to gulp.js, as follows:

inspect %USERPROFILE%\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js

Can you please add a small warning in the Wiki that Windows users will need to do something like this? Even nicer, it would be great if the code would automagically do the right thing under Windows (know to look for the js file instead of the cmd files). These seem to always be under

\bin\.js. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or mute the thread .
jaridmargolin commented 7 years ago

@cowwoc @mightyiam - one comment in the thread suggested the following fix on windows node --debug $(which gulp) taskname... Under the hood inspect-process actually attempts to use which (or at least a node port of it). I will be willing to investigate the issue further to see if there is a possible solution. If there is not, I will definitely update the README.

Thanks for the report.

cowwoc commented 7 years ago

@jaridmargolin I don't see how that could work seeing as:

  1. which doesn't ship out-of-the-box with Windows.
  2. When I invoke which gulp under my system (after manually installing which) I get no match, but which gulp.cmd does get a match. Even if which was somehow working, it would probably match gulp.cmd instead of the final executable.

UPDATE: That said, if you want to add some test code, I'm more than happy to try it out and report back to you.

jaridmargolin commented 7 years ago

@cowwoc - The module being used under the hood of inspect-process works cross platform.

If it returns the cmd, I should be able to resolve that to use the actual executable instead? I will have to do more digging. I have a Windows VM on my machine, so I should be able to give it a quick look when I have a spare minute.

Or of course, if you wanted to investigate and submit a PR, I would have no objections 😝

cowwoc commented 7 years ago

@jaridmargolin Yes, as far as I can tell, once you have the path of gulp.cmd, you can simply invoke bin/gulp relative to the same directory and it'll work. I checked one other module, and the paths convention seems to be the same (the cmd always invokes bin/module_name under the hood).