# ESM

* ECMA에서 채택
* 가져오기 &#x20;

  ```javascript
    import module_name from module_position
  ```
* 내보내기

  ```javascript
    export
    export default
  ```

  * default 없이 내보냈을 경우, import 해올때 {func1, func2}
  * default 붙여서 내보냈을 경우, import 해올때 객체이름 지어주고
    * 기능 사용시, 객체이름.func1 이런식으로 사용가능
* nodeJS에서는 CommonJS를 기본적으로 따르기 때문에, ESM으로 모듈을 사용하려 외부 모듈이 필요하다.

  ```
    npm install esm
  ```
* 실행시 명령문(기존에 `node 파일명`)

  ```
    node -r esm index.js
  ```

  * index.js파일을 esm 모듈을 사용해서 실행
  * r: 모듈을 commonJS외에도 적용가능토록하는 명령


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://minhee0327.gitbook.io/mini-til/frontend/module/esm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
