Cara mendeteksi modul JS diperlukan
if (require.main === module) {
console.log('called directly');
} else {
console.log('required as a module');
}
Emmanuel Mahuni
if (require.main === module) {
console.log('called directly');
} else {
console.log('required as a module');
}