Skip to content

VScode debug EJS files of HEXO theme? #329

@lorezyra

Description

@lorezyra

This is NOT A BUG report. Rather a request to understand how to debug EJS templates using VScode debugger.

How does one debug EJS templates in VScode?

At the moment, I'm doing this "old school" with a bunch of console.info() statements that output variable names and values. This is not a long term solution as I will need to manually remove all these lines of code from the final product.
Supposedly, there is a way to do this in VScode by adding an "attach to node" process in the debugger via the .vscode/launch.json file. I've tried to do this with the following config, but all my breakpoints show "unbound" status. Any advice is appreciated.

        {
            "type": "node",
            "name": "Hexo Theme inspector",
            "request": "attach",
            "program": "${workspaceFolder}/node_modules/hexo-cli/bin/hexo",
            "args": [
                "server",
                "-p 4001",
                "--debug"
            ],
            "runtimeExecutable": "node",
            "runtimeArgs": [
                "--inspect=4001"
            ],
            "processId": "${command:PickProcess}",
            "protocol": "inspector",
            "address": "127.0.0.1",
            "port": 4001,
            "restart": true,
            "sourceMaps": true,
            "outFiles": [
                "${workspaceFolder}/**/*.js"
            ],
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "${workspaceFolder}",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole"
        },

After running hexo clean && node --inspect-brk=4001 ./node_modules/hexo-cli/bin/hexo server -p 4001 and starting the debugger, I see "Debugger listening on ..." and "Debugger attached."

image

VScode will stop the code and step through the nodeJS files within the node_modules folder, but still doesn't stop on breakpoints set within the EJS template files. What am I missing?

Reference

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions