Debug app code

So from all your comments, for someone unexperienced like me…

How to debug in VSCode

  1. create launch.json - VSCode
  • choose RUN AND DEBUG and select settings.
    obrazek
{
"version": "0.2.0",
     "configurations": [{
             "name": "Launch app",
             "type": "node",
             "request": "launch",
             "cwd": "${workspaceFolder}",
             "runtimeExecutable": "homey",
             "args": ["app", "run", "--remote"],
             "outputCapture": "std",
             "env": {
                "DEBUG": "1"
            },
             "serverReadyAction": {
                 "pattern": "Debugger listening on",
                 "action": "startDebugging",
                 "name": "Attach to Homey"
             }
         },
         {
             "name": "Attach to Homey",
             "type": "node",
             "request": "attach",
             "address": "myhomeyip",
             "port": 9222,
             "localRoot": "${workspaceFolder}",
             "remoteRoot": "/app/"
         }
     ]
 }

(or variations for Cloud, different Homeys like above)

  1. Aplication app.js oninit update with (optional?) :
		if (process.env.DEBUG === '1') {
			require('inspector').open(9222, '0.0.0.0', true);
		}

(or variations for Cloud, different Homeys like above)

  1. configure Chrome chrome://inspect/# to listen on myhomeyip:9222

  2. run Launch APP in VSCODE via RUN - START DEBUGGING…
    vscode
    (or start manually LAUNCH APP & Attach to Homey)

  3. in Chrome launch /app//assets/app/bootstrap.mjs INSPECT - you shall see “Debugger attached” in VSCode as confirmation it’s connected

Inspector from my perspective just provide another view of what available already in VSCode but I’m sure someone more clever then me will comment on this.

And you must set Breakpoints to actually see anything and debug, also CALL STACK must be active on ATTACH TO HOMEY…

If I missed anything or misunderstood anything, feel free to comment, I will then edit this post.

Note

"localRoot": "${workspaceFolder}",
  • seems it’s not required to be changed to "localRoot": "${workspaceFolder}/.homeybuild", unless you run the code from .homeybuild (which I guess you should not)