유형: TS/git
사담
원래도 파일명의 대소문자를 수정하면 일일이 이름과 경로를 수정해야했지만, 이 문제가 route 설정, 심지어 Live Server동작에도 영향을 줄 것을 상상치도 못했다. 앞으로 이런 일은 절대 없도록 해야겠다.
에러 메시지
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of ___. Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports...
: npm start를 실시 후, 문제 페이지의 주소를 입력하였을 때 뜨는 에러 메시지이다.
해결법
1) 애초에 문제를 만들지 않는다. 파일/폴더명을 신중히 정해 중간에 수정하지 말자!
2) 부득이하게 수정했을 경우, 해결 방법은 다음과 같다.
1) 문제의 파일/폴더의 상위 디렉터리로 이동한다
2) 파일의 이름을 temp 등으로 수정한다.
- temp가 아니어도 된다. 앞서 말했듯 git은 대소문자를 구분하지 못해 temp에서 Temp로 수정이 불가능하기 때문이다
- 아래를 참고하여 git mv login.jsx Login.jsx를 입력할 경우, fatal: bad source 라는 메시지가 뜨며 실행이 불가능하다.
3) git add . 로 파일을 스테이징한다.
- 스테이징하지 않으면 not under version control 라는 메세지가 뜨며 실행이 불가능하다
4) git mv temp.확장자 WhatYouWanted.확장자
5) 소스코드 내 (특히 export와 import에) 파일명과 경로가 제대로 바뀌었는지 확인한다.
참고한 자료(출처)
https://blog.benhammond.tech/dont-change-the-capitalization-of-your-filenames
Don't Change the Capitalization of Your Filenames!
Renaming of a file's casing will be ignored by git, and by extension GitHub and Heroku deployments
blog.benhammond.tech
Git says "not under version control" for just-checked-out file
I have the distinct impression my Git repo is somehow mangled. Here's the sequence I'm doing: git clone [remote's clone string] This creates, among many others, a file "App/android/AndroidMan...
stackoverflow.com
[git린이탈출기] 폴더이름 변경하기
이슈가 생긴 정황 vscode에서 폴더이름을 변경하였다. github에 전-혀 반영되지 않았다. 이것은 내가 저번에 작성한 대소문자 이슈구나! 그래서 게속 소문자로 남아있구나. 그렇다면 git을 이용하자.
velog.io
'Project > 24-1 Everywhere' 카테고리의 다른 글
[Others] 나만 몰랐던 UI 편리하게 구현하는 도구 (4) | 2024.08.16 |
---|---|
[Git] Git으로 협업하기 - pull(merge) vs rebase (1) | 2024.08.13 |
[Git] 이전으로 돌아가기 - git restore/git reset (0) | 2024.08.13 |
[React, Others] 협업 시, ESlint & Prettier 기본 설정 (0) | 2024.08.10 |
[React] package.json과 의존(dependency) (0) | 2024.08.08 |