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.

Examples:
a.js

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

b.js

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

http://www.cnblogs.com/dolphinX/p/3485260.html
http://www.cnblogs.com/kongxianghai/p/3936197.html