How does exports’ method access closure variables

  node.js, question

How to Distinguish Internal Variables from External variable?

var name = 'im a module';
 exports.setName = function (name) {
 //how to distinguish between two names, the requirement is that the first name is the external name and the second name is the parameter name
 name = name;
 exports.sayName = function () {
 Log ('hello' plus name);

It is good that the parameter name is different from the variable name in your module.
If you want to access variables of the outer layer, then your module must provide methods to receive variables or methods of the outer layer module.
Your module cannot predict whether a variable of the outer module must exist or not. It can only passively receive the call notification of the outer module

//export an assignment method
 exports.setName = function (nameIn) {
 name = nameIn;