Wednesday 25 March 2020

Problem debugging Node.js application in WebStorm

Hello,I'm completely new to Node.js, coming over from c++. I'm trying to make a module for an existing node.js application. Essentially I'm just writing a function to parse a text file with a specific format. I can't set up the parent application in Webstorm so I tried just make a simple html file to call a script, which then calls my module. However, while my script seems to be launched, my module doesn't get called. My code looks as follows:E:\Productivity\WebStorm 2019.3.4\Projects\mysettingsparser\Caller.html Title E:\Productivity\WebStorm 2019.3.4\Projects\mysettingsparser\index.jslet patcherPath = "S:\\ParentScript\\Modules\\MyModule"; let settingsLoader = require('E:\\Productivity\\WebStorm 2019.3.4\\Projects\\mysettingsparser\\settingsLoader.js'); function go() { document.write("hello!"); document.write(settingsLoader.testfunction()); settingsLoader.loadPackSettings(patcherPath); } E:\Productivity\WebStorm 2019.3.4\Projects\mysettingsparser\settingsLoader.jsmodule.exports = { testfunction: function() { return "Testing!"; }, loadPackSettings: function(patcherPath) { document.write("Loading!"); let fs = require('fs'); let resourcePath = patcherPath + '\\ResourcePackSettings\\'; // path to resource pack files // look in path and pull candidate files let returnstring = ""; let files = fs.readdirSync(resourcePath); let groupAndFileNames = []; // names of groups in text file for (i = 0; i < files.length; i++) { groupAndFileNames = validatePackSettings(resourcePath, files[i]); for (j = 0; j < groupAndFileNames.length; j++) // go through each group name { returnstring += groupAndFileNames[j][0] + " (" + groupAndFileNames[j][1] + ")"; } } return returnstring; } }; //ValidatePackSettings is defined here but irrelevant (I think) to my problem When I open the html in WebStorm, launch it through Internet Explorer, and click "Start loader", I get the message "hello!" displayed, but then nothing happens (it doesn't call testfunction() and display "Testing!"). I tried setting breakpoints at every line in index.js but when I click debug in Webstorm, it breaks at let PatcherPath, then let settingsLoader, and then it skips all the way to the closing } of the go() function. I think that the overall syntax is correct because WebStorm's autocomplete function recognizes both testfunction() and loadPackSettings(patcherPath) when I call them from index.js.It seems to me that I'm misconfiguring something - the debugger isn't listening to the html file, and then for some reason it skips over my go function even though the first part of go() works because I get "hello!" on my html page.​If someone could give me a hint, I'd really appreciate it!

Submitted March 25, 2020 at 07:01AM by Piranha91

No comments:

Post a Comment