- module一个对象,每个文件都会有,可以直接
console.log(module)
{
id: '.',
path: 'd:\\workspace\\nodejs\\test',
exports: {},
filename: 'd:\\workspace\\nodejs\\test\\test.js',
loaded: false,
children: [],
paths: [
'd:\\workspace\\nodejs\\test\\node_modules',
'd:\\workspace\\nodejs\\node_modules',
'd:\\workspace\\node_modules',
'd:\\node_modules'
]
}
- 一般情况下,exports和module.exports指向同一个空对象
{}
console.log(module.exports,exports)
console.log(module.exports === exports);
module.exports = 'test';
console.log(module.exports,exports)