Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VScode debug EJS files of HEXO theme? #329

Open
lorezyra opened this issue Feb 24, 2023 · 0 comments
Open

VScode debug EJS files of HEXO theme? #329

lorezyra opened this issue Feb 24, 2023 · 0 comments

Comments

@lorezyra
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant