Before you start!
npm install profoundjs
'. Click here for more detailed installation instructions.Please note...
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:
- https://code.visualstudio.com/
- https://code.visualstudio.com/docs/editor/whyvscode
- https://code.visualstudio.com/docs/nodejs/nodejs-tutorial
- https://code.visualstudio.com/docs/nodejs/nodejs-debugging
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:
{ "type": "node", "request": "launch", "name": "Launch Profound.js", "program": "${workspaceFolder}\\profoundjs\\start.js", "args": [ "--no-worker" ] }
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.
- In the VS Code explorer, open 'modules/pjssamples/connect4.js'
- 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.
- Next, start debugging from VS Code and launch the application in your browser using the URL which is shown the debug console.
- 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.