Skip to end of metadata
Go to start of metadata

 

 

Before you start!

The first step is to install Profound.js onto your local machine by using 'npm install profoundjs'. Click here for more detailed installation instructions.

Please note...

You can and are welcome to use any Node.js debugger you prefer with Profound.js; however, this walk-through illustrates using VS Code, as it is one of the more popular, free, and easy to use debuggers for Node.

VS Code: The What and Why

VS Code is a cross-platform, multi-language code editor. With inline IntelliSense, debugging support for multiple languages, inline git support and an extensible API for plugins, it's the editor that has no boundaries.

It's inline debugging support is perfect for Profound.js as it provides the functionality to start and stop Profound.js locally, set breakpoints, and see the values of variables at runtime, all through a friendly user interface.

To download and read more about VS Code, check out the following links:

Written Tutorial

VS Code Debug Setup for Profound.js

For VS Code, you will want to open your Profound.js installation directory in the Explorer. This is so it's easy to navigate and debug through existing source.

  • File -> Open Folder...
  • Select the directory where you installed Profound.js

You will also want to create a new debug configuration, which would look like this:

launch.json file in VS Code

This specifies that when you start debugging, it will launch Profound.js inside of your VS Code instance.

To test that this debug configuration is working, when you start debugging you should see the following in your 'DEBUG CONSOLE':

Once you have your Profound.js server running from VS Code, that means you are now able to debug.

 

Debugging a Profound.js module

For this example we will debug connect4.js, an example module shipped with Profound.js.

  1. In the VS Code explorer, open 'modules/pjssamples/connect4.js'

  2. When the file is open, set a breakpoint on where you'd like to break the program. You can set a breakpoint by clicking slightly left of the line number you'd like to break on.

  3. Next, start debugging from VS Code and launch the application in your browser using the URL which is shown the debug console.

  4. When the program breaks, VS Code will take focus and the current debugging line of the statement will be highlighted in yellow.


    From here, you are able to step through your module and debug the application.

Video Tutorial

Labels
  • No labels