Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can debug Profound.js modules on your local machine.

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

This guide will show you how to debug an application. The example application used here is the same application generated in the Generating Profound.js Modules with JumpStart guide.

 

Step 1 - Setup

First, copy the source that you'd like to debug (and dependencies for that source) from your IBM i onto your local machine.

For example, if your Profound.js module was stored in /profoundjs/modules/demolib/prodapp.js on your IBM i, then you would copy it to /profoundjs/modules/demolib/prodapp.js on your local machine.

If you have to copy a Profound.js module into a directory that does not exist on your local machine yet, do not forget to add it to your pathlist in your Profound.js server settings.

Image Removed

 

Step 2 - Test

Once you have copied the source to your local machine, you should test that your IBM i can reach your local machine.

  1. In a Genie session, use command PJSMYIP. This changes your session to point to your local Profound.js server. For more details, click here.
  2. Now, start your local Profound.js server. To do this, change your current directory to your Profound.js installation directory and use 'node start.js' to start the Profound.js server.
  3. Lastly, call your program from Genie: CALL PRODAPP. This will redirect the call to your local Profound.js server, where the JavaScript is run.

 

...

What is and why VS Code?

VS Code is a cross-platform, multi-language support 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, see the value of variables at runtime, all through a friendly UI.

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

VS Code Debug Setup for Profound.js

For VS Code, you will want to open your Profound.js directory as your workspaceinstallation 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
    Image Added

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

...

This specifies that when you start debugging, it will launch the Profound.js inside of your VS Code instance. This allows you to put breakpoints into Profound.js modules.

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

Image Removed

To debug our application, open the file in VS Code and set a break point. To test, we will set one at the Profound.js module entry point

Image Added

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'

    Image Added
  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.

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

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

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