How does Nodejs and Express refer to a js file of the public file inside in main.js?

  node.js, question

For example, I want to write a bunch of function in utility.js and call them in main.js what should I do?
I have tried many methods on the internet, but they have not succeeded.

Thank you for your advice.


module.exports.getName = function(){};


var a = require("a.js");
 var b = a.getName();

In short, variables or methods that you want to leave to external references in a js file are passed to themodule.exportsI wish I could …,
And then in another filerequireLast js