변수/함수/클래스 앞에 export를 붙인다.
export function test_func() {} export class TestClass { }
// 내장객체는 아래처럼 불러 왔는데... const path = require('path');
// 내장모듈 import path from 'path'; // 내가 작성하는 부분 import { CustomClass } from "./CustomClass.js";
node.js 를 사용한다면 ES모듈의 경우, package.json
에 모듈 방식을 사용할 것을 적어야한다.
package.json
{ "name": "cmdtool", ..... "type":"module" // <- 추가할 키워드 }