반응형 node java1 [Node.js] java의 class 처럼 모듈 빼서 사용하기 1. 하는 이유 app.js 파일을 지저분하게 만들기 싫어서 나는 자바, c#등이 익숙해서 비슷하게 쓰고 싶어서 2. test.js 파일 만들기 function printABC() { console.log("ABC"); } function printCDE(){ console.log("CDE"); } //하나 또는 여러개의 함수를 추가할때 module.exports = { PrintABC: printABC, PrintABC: printCDE, }; 3. app.js 파일 수정하기 var test = require('./script/test'); //test.js 파일만든 위치 test.PrintABC(); test.PrintCDE(); developer-mango.tistory.com/5 [Node.js].. 2021. 3. 7. 이전 1 다음 반응형