node js if name main

// Step 1: Import the required modules
const fs = require('fs');

// Step 2: Define the main function
function main() {
    // Step 3: Check if the script is being run as the main module
    if (require.main === module) {
        // Step 4: Perform actions specific to the main module
        console.log('This script is being run directly.');
    } else {
        // Step 5: Perform actions if the script is imported as a module
        console.log('This script is being imported as a module.');
    }
}

// Step 6: Call the main function
main();