Page 90 - Nodejs 교과서 개정2판
P. 90
meਸ ֍যفݶ प೯ द അ ੌݺҗ അ ੌ ҃۽۽ ߄Ջפ
filename.js
console.log(__filename);
console.log(__dirname);
콘솔
$ node filename.js
C:\Users\zerocho\filename.js
C:\Users\zerocho
҃۽ח ৈ۞࠙ ҃۽৬ ܵפ ژೠ ਦبо ইפۄݶ \ न /۽ ಫ؊ ҃۽о ҳ࠙ؼ ࣻ णפ ۧѱ
ࠁܳ ࢎਊ೧ࢲ ҃۽ ܻܳ ೡ ࣻب णפ ೞ݅ ҃۽о ޙৌ۽ ߈ജغӝب ೞҊ \ա / э ҃۽
ҳ࠙ ޙઁب ਵ۽ ࠁా ܳ ೧Ѿ೧ח QBUI ݽٕ ଵઑ җ ೣԋ ॺפ
NPEVMF FYQPSUT SFRVJSF
Әөח ݽٕਸ ٜ݅ ٸ module.exports݅ ࢎਊ೮חؘ module ё ݈Ҋ exports ё۽ب ݽٕਸ ٜ݅ ࣻ
णפ
WBS KTܳ җ э ࣻ೧ب JOEFY KTীࢲח زੌೞѱ ࠛ۞ৢ ࣻ णפ
var.js
exports.odd = '홀수입니다';
exports.even = '짝수입니다';
콘솔
$ node index
짝수입니다
홀수입니다
module.exports۽ ೠ ߣী ੑೞח न пп ߸ࣻܳ exports ёী ೞաঀ ֍णפ زੌೞѱ زೞ
ח ਬח module.exports৬ exportsо э ёܳ ଵઑೞӝ ٸޙੑפ पઁ۽ console.log(module.expo
rts === exports)ܳ ೞݶ trueо ա২פ ٮۄࢲ exports ёী add ೣࣻܳ ֍ਵݶ module.exportsীب a
dd ೣࣻо ٜযцפ