// greet.js
exports = { hello: () => "hi" };
// main.js
const m = require("./greet");
console.log(typeof m.hello);
undefined
exports is just a local variable. At the start it points to module.exports. Reassigning exports breaks that link. require always returns module.exports, which is still the empty object. Use module.exports = { ... } instead, or add properties with exports.hello = ....
Read more