How to call a function in a server side node file from a client side file

I have a Node.js file that contains a function which writes to local files. I need to call this function from a client side JavaScript file. How can you do this?

I have seen questions about how to call server side functions on an HTML event, but not just strait from a client side script at any time.

Here is the script to write to the local file:

function writeCreateFile(filePath, newValue, callback) {
  checkIfFileExists(filePath, function(exists) {
    if(exists){
      fs.writeFileSync(path.join(__dirname, filePath), newValue, 'utf-8')
    } else {
      fs.appendFileSync(path.join(__dirname, filePath),newValue);
    }
    callback();
  })

}

function checkIfFileExists(filePath, callback) {
  fs.readFile(filePath, 'utf-8', function(err, data) {
   callback(err);
 });
}