I'd like to start a Nodejs debugger for my Hexo blog to understand how my theme works and possibly find a bug.
I needed 2 things to achieve this:
hexo-cli
as a dev dependency rather than global. I used npm i hexo-cli --save-dev
.package.json
, under scripts
, add a script called debug
. I used this command: node --inspect=4300 ./node_modules/hexo-cli/bin/hexo server
.Then just use npm run debug
and you're good to connect with a debugger to port 4300 (or whatever port you want to set in your command) and do line-to-line debugging etc.
One caveat is that with the --inspect
setting, for some reason hexo is starting extremely slow (takes more than 2 minutes). I wonder what causes this.
Also, I haven't found a way to start hexo in a way that it generates pages dynamically. It would help with real time debugging.