자바 스크립트, 노드 모듈 사용법

Sizz-J

·

2021. 4. 22. 18:15

- JavaScript -

module.js {

export default { var text = "Hello World" }

}

 

use.js {

import Test_Any from './module.js'

console.log(Test_Any.text);

}

 

실행방법: html에 use.js를 연동하여 테스트.

결과: Hello World

 

 

- node.js -

module.js {

module.exports = "Hello World"

}

 

use.js {

var Test = require('./module.js');

console.log(Test);

 

실행방법: node use.js

결과: Hello World

 

728x90