''안에 동일한 '' 쓰면 에러발생. 다른 따옴표를 쓰자.
Uncaught SyntaxError: Unexpected token '<'
- 말그대로 '<' 를 잘못 사용했다는 말
Uncaught SyntaxError: Unexpected end of input
- 괄호를 제대로 잘 닫지 않아서 생기는 에러
Uncaught TypeError: Cannot read properties of undefined (reading ~)
- 값이 정의 되지 않아 읽을 수 없을 때 발생하는 에러
원인 :
- 페이지가 최초 렌더링 되었을 때 state는 undefined이고, state는 비동기로 동작한다.
그래서 렌더링 전이라 아무것도 읽히지 않는 상태에서 동작하기 때문에 undefined라고 결과값이 나온다.
해결방안 :
- State에게 들어올 값의 타입을 미리 알려주면 undefined를 출력하지 않는다.
Uncaught SyntaxError: Invalid or unexpected token
- 에러가 발생한 라인에 오타확인하기.
- 쌍따옴표로 문자열 감싸주기, 콤마(,)의 위치, 소괄호, 중괄호 등 (), {} 괄호 열림, 닫힘이 잘못된 부분이 없는 지확인 후 수정
Uncaught SyntaxError: Illegal return statement
- 함수도 아닌데 return을 써서 난 오류. 조건문에서 썼다면 지워라.
포스트맨에서 post 시 무한 로딩이 걸리는데, DB에는 데이터 저장될 경우
- 코드에서 await랑 async 잘못 썼을 확률이 크다. 그거 확인해라.
ERROR [ExceptionsHandler] Cannot add or update a child row: a foreign key constraint fails (`myproject03`.`product`, CONSTRAINT `FK_618194d24a7ea86a165d7ec628e` FOREIGN KEY (`productCategoryId`) REFERENCES `product_category` (`id`))
- FK값 빼먹어서 그런거니까 꼭 써라
RepositoryNotFoundError
- app.module.ts에서 entities 경로를 제대로 입력해서 고침. 경로 잘봐라
Access denied for user 'root@'@'localhost'
- database 비밀번호 값이 잘못되서 그런거다. mysql 초기값으로 해보던가 app.module.ts에서 설정한 비밀번호 다 시도해 봐라.
GraphQLError: Query root type must be provided.
Error: Schema generation error (code-first approach)
- 이 두 에러는 세트인데, 요지는 하나, GraphQL 관련해서 코드 잘못짜서 그런거다.
나같은 경우 데코레이터는 다 썼는데 에러가 자꾸 나서 확인해보니, resolver.ts에 @Mutation은 썼는데 @Query는 안써서 에러가 발생했다. 나는 @Query에 쓸 코드를 아직 생각하지 않아서 아예 작성조차 하지 않았는데, 그게 에러의 원인이였다.
어떤 함수에 @Query를 붙일 지 생각을 아직 하지 않았더라도 무조건 데코레이터는 일단 작성해둬야지 된다. 참고로 데코레이터는 함수가 있어야지 쓸 수 있으니 콘솔을 찍는 함수라도 만들어서 데코레이터를 붙여줘라. 기능은 나중에 생각해보거라.
Found non-callable @@iterator
- 나의 경우 resolver랑 service에서 spread 연산자를 잘못써서 났었다. { ...변수명 } 의 형태로 제대로 썼는지 확인해보자.
Error: Nest can't resolve dependencies of the UserService (?). Please make sure that the argument Repository at index [0] is available in the UserModule context.
- 나의 경우에는 Service에 Repository 의존성 주입을 빼먹어서 에러가 났다. constructor에 Repository를 주입하고 @InjectRepository(타입) 을 빼먹지 않았는지 확인해보자.
RepositoryNotFoundError: No repository for "User" was found. Looks like this entity is not registered in current "default" connection? Typeorm
- 나의 경우에는 app.module의 entities에 Entity를 추가하는 것을 깜빡했다. 쓰고있는 Entity를 다 가져왔는지 확인해보자
Column 'contents' in where clause is ambiguous
- 서로 다른 테이블을 조인했을때 같은 컬럼이 있으면 생기는 에러. 어떤 테이블의 컬럼을 조회해야 하는지 명확하지 않을 경우 발생하는 에러이다.
예를 들어 테이블1에도 contents이라는 컬럼이 있고 테이블2에도 contents이라는 컬럼이 있다고 친다. 두 테이블을 조인한 뒤 contents이라는 컬럼을 조회하려고 하면 테이블1의 contents인지 테이블2의 contents인지 명확하지 않기 때문에 error가 발생한다. 어떤 테이블의 contents인지 지정해주면 해결된다.
참조 : https://velog.io/@louis220/Column%EC%BB%AC%EB%9F%BC%EB%AA%85-in-where-clause-is-ambiguous
https://lts0606.tistory.com/505
Error: "Mutation.deleteEpisodeReview" was defined in resolvers, but not in schema.
- Mutation에 반환 타입 명시 안해줘서 생기는 에러. 타입 지정해주자.
TypeError: Cannot read properties of undefined (reading 'id')
- 반환되는 값 중에 값이 undefined라 찾을 수 없을 경우 생기는 에러.
가령 id의 값이 무조건 반환이 되게끔 코드가 짜여져있는데, 반환될 때 값이 undefined이라서 생기는 에러. 반환값을 일일이 콘솔 찍어보면서 어디서 문제가 생겼는지 확인해보자. 오타, 객체접근 등 이유가 다양할 경우가 많다.
GraphQL query Error Message: Field \create\ argument \page\ of type \Float!\ is required, but it was not provided.,
- 인자를 받아야하는데 받지 않을때 나는 에러로, 인자를 입력해주어야 한다. import도 빼먹지 않았는지 확인 요망.
Graphql upload getting "Invalid JSON in the ‘operations’ multipart field"
- https://stackoverflow.com/questions/62569041/graphql-upload-getting-invalid-json-in-the-operations-multipart-field
NestJS : circular dependency
- ManyToOne & OneToMany 등의 관계에서 의존성 주입을 서로에게 서로를 했을 경우 발생하는 에러. 강제로 해결하는 방법이 있지만 비추하므로 의존성을 한쪽에선 해제하는 방법을 추천.
https://velog.io/@peter0618/NestJs-circular-dependency-%EB%AC%B8%EC%A0%9C-%ED%95%B4%EA%B2%B0
https://velog.io/@adguy/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EB%AC%BC%EC%9D%8C%ED%91%9C-%EB%91%90%EA%B0%9C
Field 'title' doesn't have a default value
- null값이 들어오면 안되는데, null값이 들어와서 생기는 오류.
entity에 nullable: true를 주면 임시방편으로 해결은 될 수 있으나, 근본적인 해결은 아니므로, null이 될 수 없는 값에, null로 값을 넣을 수 없게끔 조치를 취하는 것이 좋음.
https://namsieon.com/24
https://velog.io/@dlehdus97/SQL-%EC%98%A4%EB%A5%98-%EB%B3%B4%EB%8A%94%EB%B2%95
'❗❗ ERROR ❗❗' 카테고리의 다른 글
[🚨️ERROR🚨️] Uncaught SyntaxError: Invalid or unexpected token (0) | 2022.08.01 |
---|---|
[🚨️ERROR🚨️] Uncaught TypeError: Cannot read properties of undefined (reading ~) (0) | 2022.07.31 |
[🚨️ERROR🚨️] Uncaught SyntaxError: Unexpected end of input (0) | 2022.07.31 |
[🚨️ERROR🚨️] Uncaught SyntaxError: Unexpected token '<' (0) | 2022.07.31 |
[🚨️ERROR🚨️] 첫 에러 '' 와 "" 구분 (0) | 2022.07.30 |