![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128144745852-363610894.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128144811523-1752753884.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128144851275-1673143688.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128144940626-1215654681.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128145005816-1604545035.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128145127004-1527417916.png)
// console.log(112);
const add = (n1, n2) => n1 + n2;
exports.add = add;
// const a = require('./03.module-a.js');
const a = require('./03.module-a');
console.log(a.add(10, 20)); // 30
console.log(111); // 111
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128145420209-1967504336.png)
![](https://img2018.cnblogs.com/blog/1877004/202001/1877004-20200128145717790-1173070071.png)
const greeting = name => `hello ${name}`;
const x = 100;
exports.x = x;
module.exports.greeting = greeting;
// 当exports对象和moudle.exports对象指向的不是同一个对象时 以module.exports为准
module.exports = {
name: 'zhangsan'
}
exports = {
age: 20
}
const a = require('./04.module.exports.js');
// console.log(a.greeting('zhangsan'));
console.log(a); // { name: 'zhangsan' }