Finds customer who live within 100km and output them to a text file
Generally I find the code very unstructured making reading it a bit confusing:
First you execute some code outside of a function to read the data from a file, then you define a constant (dublinOffice), then you define a variable (invitedArr), but don't use it in the next block of code, then you sort the data, then you define two functions, and finally execute one of the functions.
Further more the function closestCustomers both gets invitedArr passed an argument (and uses it as such) and uses it directly as a global variable.
Personally I'd have the main code calling functions first (after defining constants) and then define all functions at the end of the source code using function so that they are hoisted. Other people may define the functions first and then use them, but that is a matter of taste, as long it's not all mixed up.
More, smaller functions would also be helpful. Reading the data should be in its own function and closestCustomers does too much (filtering, converting the objects to strings, and calling writeInvitedCustomer). This would also make testing easier.
Using the array methods filter() and map() would help the code be more readable. Personally, I'd start with something like:
const inputFileName = &quot;customers.txt&quot;;
const outputFileName = &quot;output.txt&quot;;

const dublinOffice = {
  latitude: &quot;53.339428&quot;,
  longitude: &quot;-6.257664&quot;,
};
const maxDistance = 100;

const invitedCustomers = readCustomers(inputFileName)
  .filter(withinKms(dublinOffice, maxDistance ))
  .sort(userIdComparator)
  .map(formatCustomerForOutput); // `map` may be considered to be moved inside `writeInvitedCustomers`

writeInvitedCustomers(invitedCustomers, outputFileName);


function readCustomers(filename) {
  // ...
}

function withinKms(location, kms) {
   return (customer) =&gt; greatCircleDistanceCalc(customer.latitude, customer.longitude, location.latitude, location.longitude) &lt;= kms;
}

function userIdComparator({user_id: userId1}, {user_id: userId2}) {
   return userId1 - userId2;
}

function formatCustomerForOutput({name, user_id}) {
   return `${name}:${user_id}`;
}

// etc.


One other point: I'm not familiar with node's WriteStream, but it looks wrong for me to assign the event handlers after using it by calling its write method. Can't write cause an error?
NB: This is probably not your choice, if this was an interview task, but I find the file format for customers.txt (multiple JOSN objects in one file) strange. A straight forward JSON array would make more sense.