Require in node imports the module, but there is no definition of naming. How to use the function calling module inside

  node.js, question
Required ('module1')//does not have a name defined. how do you use it?
 Varmodule2 = require ('module2')//Functions of module inside can be called using module2

Batch import module

Var models_path = __dirname plus' /app/models'
 var walk = function(path) {
 fs
 .readdirSync(path)
 .forEach(function(file) {
 Var newPath = path plus'/'plus file
 var stat = fs.statSync(newPath)
 
 if (stat.isFile()) {
 if (/(.*)\.(js|coffee)/.test(file)) {
 require(newPath)
 bracket
 bracket
 else if (stat.isDirectory()) {
 walk(newPath)
 bracket
 })
 bracket
 walk(models_path)

How does the module imported here call the method of module inside? If the module cannot be used in this way, can the module be imported in batch and used?

Use global variables for module inside. However, it is not recommended. Maintenance is troublesome. You should specify a name and use a variable to store it.

let modules = {}
 //Circulatory Body
 Modules[ File Name] = require (File Path)
 
 //call
 modules.somemodule