Export


1
2
3
4
5
6
var exports = module.exports = {};
 
 
exports.name = function(){
    //doSomething
};
cs

.js 파일은 만들고 위와 같이 입력한다.
함수를 사용할때는 4-6라인처럼 입력하면된다.


Import

1
const db = require('../routes/sample.js');
cs

export와 import를 이용하여 코드를 깔끔하게 작성할 수 있다.


'Programming > Node.JS' 카테고리의 다른 글

지금 현재 서버의 ip를 알고 싶을때  (0) 2016.09.14
mysql 모듈  (0) 2016.09.05
Cluster  (0) 2016.09.05
코딩의 관례  (0) 2016.09.05
express.js 구조  (0) 2016.09.05

+ Recent posts