how to detect writes in the command line node js code example
Example: node js check if called from command line
if (require.main === module) {
console.log('called directly');
} else {
console.log('required as a module');
}
if (require.main === module) {
console.log('called directly');
} else {
console.log('required as a module');
}