https://poiemaweb.com/nodejs-module
잘 정리된 것 같다.
module.exports 의 경우 기본적으로 한 개의 모듈만 내보낸다고 보면 된다.
hi.js
module.exports = () => {
return {
ang() { return 'ang' },
angli() { return 'angli' }
};
}
app.js
const hi = require('./hi');
console.log(hi().ang());
console.log(hi().angli();
hi.js
exports.ang = () => {
console.log('hi');
}
exports.angli = 'angli';
app.js
const hi = require('./hi');
hi.ang();
console.log(hi.angli);
'IT > 공유' 카테고리의 다른 글
[공유] https. ubuntu apache2 openssl 적용 (0) | 2019.10.16 |
---|---|
[공유] React Code Splitting (0) | 2019.10.15 |
[공유] firebase RealtimeDatabase vs Cloud Filestore (0) | 2019.10.11 |
[공유] 쿠버네티스, 도커 (0) | 2019.10.08 |
[공유] firebase (0) | 2019.10.02 |