If your code detects that it is called by require, you may want it to branch accordingly, doing or not doing certain things in each case. How do I do this?
Sure, just check if module.parent is not null or undefined. If it is set with an object, then your module is being called with require.