HANA -J

TIL - node.js require, import 본문

what I Learnd/TIL

TIL - node.js require, import

Hana-J 2022. 2. 16. 21:59
  • require : CommonJS에서 모듈을 불러올 때 사용하는 키워드
module.exports = {
    getPrivateNotice
}
//사용
const privateControll = require('../controller/privateList');

 

 

 

  • import : ES6에 도입된 키워드, 다른 패키지 안에 있는 클래스, 메소드, 변수 등의 데이터를 사용하고자 할 때 사용하는 키워드
export const hello = 'hello' 
//사용 
import {hello}


export default NumberBase;
//사용
import NumberBase;

 

728x90

'what I Learnd > TIL' 카테고리의 다른 글

클래스 101 : 팔리는 글쓰기 (1)  (0) 2022.09.15
TIL - node.js 미들웨어  (0) 2022.02.18
TIL - OSI 7 계층, TCP/IP 4 계층  (0) 2022.02.09
TIL - Nest.js  (0) 2022.02.08
TIL- AWS EC2  (0) 2022.01.20
Comments