Search code examples
node.jsdebuggingvisual-studio-codeadonis.jsdd

How can i debugging my adonis ( nodejs ) framework APIs?


I'm just beginner in adonis framework in NodeJS but I have a good experience in laravel and lumen framework

in laravel and lumen framework APIs I use dd() dump and die to debugging my app

but in the AONIS framework, I don't know how to debug my API code.

for IDE = I'm using Microsoft visual studio ( VS Code )


Solution

  • Read this : https://code.visualstudio.com/docs/nodejs/nodejs-debugging (from @damitj07)

    In summary :

    You need to create new lauch.json like:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Debug",
                "type": "node",
                "request": "launch",
                "cwd": "${workspaceFolder}/yourApp",
                "runtimeExecutable": "npm",
                "runtimeArgs": [
                    "run-script",
                    "debug"
                ],
                "port": 9229
            }
        ]
    }
    

    and add new script in your package.json like:

    "scripts": {
        ...
        "debug": "node --nolazy --inspect-brk=9229 server.js"
      },