codestates / codestates/33Plan

[Error] Back_ES6 import 형식으로 디렉토리를 불러올 때 발생하는 오류

Open
#43 0 comments 0 reactions 1 assignee Claimed by @SsankQ View on GitHub
Back-end Completed Error
Dominant language
JavaScript
Stars
2
Forks
4
PR merge metrics
No merged PRs in 30d

Description

> 해결된 에러라면 라벨에 'Complete' 를 달아주세요.
> 미해결된 에러라면 라벨을 'In progress' 로 변경해주세요.

### 어떤 에러인가요?
- CommonJS 형식이 아닌 ES6 import 형식으로 Directory를 불러올 때 정상적으로 불러오지 못하며 에러가 발생

### 에러 메시지

```bash
Directory import '폴더 경로' is not supported resolving ES modules imported from '폴더 경로'
Did you mean to import '상세 파일 경로'?
```

### 에러 핸들링 방법

- 디렉토리를 지정해주면 import Error가 발생하므로 상세 파일까지 직접 지정했더니 해결되었다
- 위 방법 말고도 CommonJS 형태로 변경하여 `require`를 통해 불러오는 것으로도 해결할 수 있었다

### 에러 핸들링을 위해 참고한 레퍼런스 링크

> *[https://github.com/sveltejs/kit/issues/612](https://github.com/sveltejs/kit/issues/612)*
> *[stack over flow](https://stackoverflow.com/questions/64453859/directory-import-is-not-supported-resolving-es-modules-with-node-js)*

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.