//定义和暴露模块
module.exports = {
foo() {
console.log("module1 foo() is called")
}
}
//定义和暴露模块
module.exports = function () {
console.log("module2 function is called")
}
//定义和暴露模块
exports.foo = function () {
console.log("module3 foo is called")
}
exports.bar = function () {
console.log("module3 foo is called")
}
---------------------------------------------app.js
//模块的导入
let module1 = require("./modules/module1")
let module2 = require("./modules/module2")
let module3 = require("./modules/module3")
module1.foo()
module2()
module3.foo()
module3.bar()