At first, handling paths in NW.js can be quite tricky. The first time you might find yourself in trouble is when requiring a custom module not stored in the default
node_modules folder. Let's say, for example, this is our folder structure:
Application root - data/myData.json - js/script.js - modules/myModule.js - modules/otherModule.js - index.html - package.json
When requiring a module from the window context, the module's path is treated as relative to the application's root directory, so in our example, whether you're calling it from
js/script.js, we would proceed as shown in the following code:
When calling a module from another module, however, you should use the relative path from the current file. So, let's say we're requiring
myModule.js, which is in the same folder:
The next thing you might worry about is how to access files for I/O operations from both contexts using their...