I have the following two JS files:
/folderA/a.js
require('/folderB/b.js');
/folderB/b.js
require('ws');
The ws module is located in /folderA/node_modules/ws, hence the b.js fails to find it.
I was able to fix this by prefixing the ws in b.js like this:
require(require.main.path + '/node_modules/ws')
I’m wondering though can I make the b.js use the main module (a.js) paths to look for modules? So I can resolve the ws module from b.js without prefix.