I have a Node server which I would like to debug. Once I’ve started the server
node server.js
I want to execute functions defined in server.js from a command line. The usual Node REPL “blocks” after the server has started.
For example, if server.js defines the function addBlogPost I want to locally call addBlogPost() and observe changes in the database without passing through a GUI.
Is there an easy way to do this?
You can use the
replmodule to create a new REPL instance:Now inside the REPL you can use
pause()to callpauseHTTP()andresume()to callresumeHTTP().