Trustroots / trustroots

Travellers' community for sharing, hosting and getting people together.
https://www.trustroots.org
GNU Affero General Public License v3.0
398 stars 137 forks source link

nice to have: npm run debug #702

Closed guaka closed 5 years ago

guaka commented 5 years ago

https://stackoverflow.com/questions/33090353/how-to-use-node-inspector-with-npm-start-for-my-application

guaka commented 5 years ago

related: https://stackoverflow.com/questions/40033298/how-to-debug-a-gulp-task

simison commented 5 years ago

The standard Node-inspector is running on each npm start already for both Worker and the main app. Check console when spinning up the app.

See https://github.com/Trustroots/trustroots/blob/5e15aa47987fd335fba4fb98aaf5503cec3e73b9/gulpfile.js#L53-L55 https://github.com/Trustroots/trustroots/blob/5e15aa47987fd335fba4fb98aaf5503cec3e73b9/gulpfile.js#L87-L90

Unless I'm misunderstanding something and you meant some other kind of debugger?

simison commented 5 years ago

Feel free to re-open if there was more to this!

guaka commented 5 years ago

Ah, then maybe the question is: how to debug node stuff? :)

On Sat, Oct 13, 2018 at 5:25 PM Mikael Korpela notifications@github.com wrote:

Feel free to re-open if there was more to this!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Trustroots/trustroots/issues/702#issuecomment-429550595, or mute the thread https://github.com/notifications/unsubscribe-auth/AADVyCFm0_B1LLsu8bt3TSO0LUDJgN3Yks5ukgX4gaJpZM4XaJu8 .

simison commented 5 years ago

Do you mean how to use that debugger (see https://nodejs.org/api/debugger.html ) or something else specifically?

While the app is running, keeping eye on the console is usually plenty enough if you just want to spot errors. For breakpoints and following code flow, the standard debugger works well.

Akronix commented 5 years ago

Well, I tried to launch the debugger with the debugger; statement but I didn't work for some reason.

simison commented 5 years ago

Using Chrome;

  1. npm start
  2. Open chrome://inspect/#devices — note "Remote Target" list, should be empty for starters
  3. Press "Open dedicated DevTools for Node"
  4. Press "Add connection" and add both localhost:5858 and localhost:5859
  5. They now appear in "Remote Target" list
  6. Press inspect on whichever process you want to debug
  7. You should now have console/profiler etc available.

via https://nodejs.org/en/docs/guides/debugging-getting-started/

simison commented 5 years ago

Might be it didn't auto-initialize due because that port number doesn't seem to be configured by default (at least in Chrome) — might be "default" has changed at some point. Hope this helps!

Jagjeet commented 5 years ago

Hi, I am new and was looking at this issue/project as part of the Hacktoberfest challenge. Is it possible to get a 'Debug' section with the info in that last comment added to the Development wiki? Or if you want to add me as an editor, I am happy to do it. It would be helpful for newcomers and future reference.

simison commented 5 years ago

Hello @Jagjeet ! :wave: Happy to accept PR adding above link and a few words as a new section to https://github.com/Trustroots/trustroots/blob/master/INSTALL.md 💪

Jagjeet commented 5 years ago

Awesome! I'll jump on it shortly.