I am having the following issue - I am attempting to debug/set a breakpoint in code that is run using the vm module. The only way that I have found to accomplish this is by putting a debugger statement:
// client code, loaded in the vm module
function printMessage() {
debugger;
return 56;
}
printMessage();
Is there any other way to accomplish this? Preferably using tools such as node-inspector?
EDIT: Found a solution - by passing a string for "filename" to the executing function from vm. For example:
vm.runInThisContext(codeToRun, "someFilename.js");
this way the debugger "figures out" where exactly the code came from.