This was a point raised in #786. We can prevent require()ing files with:
if (require.main === module) {
// everything goes here
}
This might be a good idea for files which we only intend to execute (e.g. bin/shjs).
I would also consider rewriting as:
if (require.main !== module) {
throw new Error('Module should not be required');
}
// everything goes here