[node.js] 실행, 모듈


[node.js] 실행, 모듈

[node.js] 실행 방법 -- cmd 창에서 (terminal) node [js 파일 이름] -- test.js 실행 시에 node test.js node test --REPL 모드 node [실행할 코드 작성 -- 모듈 추가 : js 파일 생성 후에 main.js 모듈에서 math_tool.js 모듈을 로드할 때 const m = require('./math-tools.js'); const m = require('./math-tools'); -- 모듈 공개 : math_tool.js 모듈 안에서 exports 선언 let PI = 3.14; exports.PIVAR = PI; --- main.js 안에서 쓸수 있음 const m = require('./math-tools.js'); console.log(m.PIVAR); module.exports = 객체; #javascript #nodejs...


#javascript #nodejs

원문링크 : [node.js] 실행, 모듈