let fs = require('fs')let req = (moduleName) => { //content代表的是文件内容 let content = fs.readFileSync(moduleName, 'utf8') console.log(content + '\n return module.exports') //最后一个参数是函数的内容体 let fn = new Function('exports','module','require','__dirname','__filename',content + '\n return module.exports') let module = { exports:{} } return fn(module.exports,module,req,__dirname,__dirname)}let msg = req('./a.js')console.log(msg.msg)