본문 바로가기

프로그래밍 기초/오류코드 정리

오류 관련 (~2023.04.21)

대문자, 소문자, 입력 안한내용, 오타 등 먼저 꼼꼼하게 확인할것

package.json 에서 사용중인 버전을 확인

참고: https://github.com/microsoft/TypeScript/blob/main/lib/ko/diagnosticMessages.generated.json


☆ 해결 한것

1. 파일을 불러왔는데 작동이 안됨

1). component.ts 파일의 속성값이 제대로 들어갔는지 확인

2). FormsModule 이 Module 에 잘 들어가있는지 확인

3). Bootstrap 의 경우

- ./angular.json 의 style 에 "../node_modules/bootstrap/dist/css/bootstrap.min.css" 추가

- npm install bootstrap

- npm install --save @ng-bootstrap/ng-bootstrap

 

 

2. (오타관련) Failed to execute 'setAttribute' on 'Element': ':' is not a valid attribute name.
- DOM 과정중에서 '  :  ' 요소가 빠진것, ->  :  친 부분 중에서 오타 났으니까 확인해라.
- 내 경우는 (click : ...... ) / 괄호가 잘못쳐져있었음, (click): ....

+ 2-1. 최대 출력 오류 / Error: Maximum call stack size exceeded
- 오타, 괄호 문제일것임(아마 대괄호)

+ 2-2. error NG5002: Unexpected closing tag "div".
- <div> 가 제대로 닫히지 않았다.

+ 2-3. NG0303:

- Can't bind to '오타난 부분의' since it isn't a known property of '오타?' (used in the '오타난 위치' component template).

+ 2-4. error NG5002: Parser Error: Lexer Error:  (^[1-9]\d*$)
- 패턴 추가하다가 발생, 5002 는.... 어딘가 뭔가 들어가선 안될게 들어간 오류임. 

 

 

 

3. (버전관련) Angular 상위 버전일경우, 속성값? 더 꼼꼼하게 체크해야함. 인식 못하는 경우 많음

- 나같은 경우는 동영상이 8? 버전인데. 내가 14버전 써서....

- @ViewChild, @ContentChild 의 경우, {static : false} 추가로 고쳐지는 부분 있음

- https://angular.io/guide/static-query-migration

+ 3.1 npm ERR code ERESOLVE
         npm ERR ERESOLVE unable to resolve dependency tree

- 버전이 안맞아서 설치가 안될때, --legacy-peer-deps, --force (강제설치)

- npm audit fix --force

  (버전 문제때문에 발생하는 의존성 어쩌구 dependency tree의 보안 취약점과 해결 방안을 제공)

https://www.korecmblog.com/ERESOLVE-unable-to-resolve-dependency-tree/https://stackoverflow.com/questions/64936044/fix-the-upstream-dependency-conflict-installing-npm-packages

+ 3.2 (상세) 강제로 npm 설치를 했는데 버전 안맞아서 오류 발생할경우

- package.json 에서 버전 체크한 후 npm install 하기

- https://www.npmjs.com/ 에서 본인한테 설치된 버전이랑 같은 버전으로 다운받기

 

 

 

4. TS2322: Type 'null' is not assignable to type 'boolean'
- boolean 인데. null 로 return 하려니까 ts 에서 오류 발생
  forbiddenNames(control: FormControl): {[s: string]: boolean}  | null {
    if (this.forbiddenUsernames.indexOf(control.value)) {
      return {'nameIsForbidden': true};
    } 
    return null;
  }
-   | null 을 추가해서 해결.
https://bobbyhadz.com/blog/typescript-type-null-is-not-assignable-to-type

 

 


5. (저장 관련) error NG8002: Can't bind to 'formGroup' since it isn't a known property of 'form'.
- 저장 생활화 해라. module 저장이 안됨

+ 5-1. Error: Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)
- NullInjector error. 이유는 항상 import/providers 문제라고 한다. ? 이건 모듈쪽 문제

+ 5-2. TypeError: ctx_r3.onEditItem is not a function

- 이 또한 저장문제

 

 

 

6. (순서 문제) core.mjs:6494 ERROR TypeError: Cannot read properties of undefined (reading '읽을 수 없는 요소')

0). 발생상황: ts 보다 먼저 view 에서 이미 불러왔기 때문에 읽어들이질 못해 에러발생

- Lifecycle 쪽에서 해결하면 될 것 같다. 아직 해결전.

- 초기화를 제대로 앞단에서 해놓으면 해결되는 문제, 구현에는 문제 없으나 개발자들 콘솔창에 뻘건거 보임

+ 6-1. ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: 

Expression has changed after it was checked. Previous value: 'undefined'. Current value: '[object Object]'. It seems like the view has been created after its parent and its children have been dirty checked. Has it been created in a change detection hook?.

- 비동기 처리과정에서 발생하는 에러 https://seo-developer.tistory.com/31

- promise 로 해당 작업을 끝낸 후 진행하면 콘솔창에 에러가 사라짐!

+ 6-2. core.mjs:6494 error typeerror: cannot read properties of null (reading 'clientwidth')

Uncaught TypeError: Cannot read property 'clientWidth' of null at Object.createStore (tui-grid.js:5952) at new Grid (tui-grid.js:4950) at (index):31

- cannot read properties 는 왠만해서 불러오는 순서 전에 View 에 띄우기 때문에 발생하는 에러.

- 불러올 데이터가 있으면 체크 하고 후에 진행하면 해결됨.

+ 6-3. Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'A')

- 순서문제... 라고도 볼 수 있는데. undefined 값을 읽어서 오류가 뜨는것.

- 보내는 데이터가 문제니까. 데이터를 제대로 보내면 될것같다.

 

 

 

7.  (라우터 경로문제) at ApplyRedirects.noMatchError 

- 라우터 문제인데. 내가 지금 맡은 부분이... 라우터가 아니라 creat component 로 해결해야해서.

- 상대경로가 아니고 절대경로 ? 를 지정했더니 해결됬다. 근데 지금도 그게 절대경로인지는 모르겠네.

 

 

 

8. Error: Content and Map of this Source is not available (only size() is supported)

- 무슨 오류인지 모르겠는데 .angular 를 폴더 째로 지우고 npm install 을 했더니 해결됨

 

 

 

9. (TS 문제) error TS2779: The left-hand side of an assignment expression may not be an optional property access.

- 타입스크립트의 특징: 유형 선언이 분명해야하기 때문에 발생하는 오류

- 선택적 속성 액세스 ~ null 값 관련 에러이므로 ! 느낌표를 넣어서 해결하기

+ 9-1. ERROR ObjectUnsubscribedErrorImpl

- https://stackoverflow.com/questions/51686141/angular-objectunsubscribederror-while-resubscribe

- 찾아보니까 ts 라서. 구독 유형의 변수(newSubscription?: Subscription)를 따로 선언하고.

  구독할 부분을 할당(this.newSubscription = this.새로운구독.subscribe((initFinish: boolean) => { ... ) 해줘야한다.

- 이 변수에 unsubscribe() 함수를 호출해야 구독이 해제됨

  구독: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

  newSubscription?: Subscription

   ...

       this.newSubscription = this.구독.subscribe((initFinish: boolean) => { ... 

       ...

       this.newSubscription.unsubscribe()

       };

 

 

 

 

10. (npm 설치하다 발생한 문제) To get access to the TypeScript compiler, tsc, from the command line either:
Use npm install typescript to first add TypeScript to your project before using npx
Use yarn to avoid accidentally running code from un-installed packages

- 제대로 파악은 안됬는데. typeScript 를 삭제 후 전역으로 재설치 하였더니 해결됨

 

 

 

11. (네트워크 문제) ~~~ has encountered a connection error and is not queryable

0). 발생상황: 구동 과정에서 인터넷 연결을 바꿈

- https://github.com/brianc/node-postgres/issues/1790

- 껐다가 네트워크 연결 후 재구동

 

 

 

12. (SQL 에러) ~~~ insert has more target columns than expressions

0). 쿼리에 기입된 colunm 보다 넣을 데이터가 많은 경우

- INSERT INTO DB이름(A, B, C) VALUES (A, B, C, D);  => (A, B, C) / 3개 < VALUES(A, B, C, D) / 4개

 


★ 해결 못한것 (이러고 넘어갔는데. 나중에 발견하면...)

1. error ng8001 is not a known element

- 이거랑 연계해서 error ng6001 ? 이게 계속 뜸

0). 발생상황

     - Component 를 분해 - 통신 과정에서 발생

     - 처음부터 내가 만든 Project 랑, 강의에서 첨부한 파일이랑 둘 다 같은 오류 발생

       ~ 그러면 Project 의 구조 문제는 아닌것 같다.

     - 데이터 바인딩(이벤트 바인딩, 양방향 바인딩) 할때 발생한것 같음

1). 추측

     - 여러개 검색을 해봤는데. Module 을 읽어들이지 못함.

     - TypeScript 버전 문제라는 내용도 읽긴 했는데... 여튼 추측임.

1-2). core.mjs:7640 ERROR TypeError: Cannot read properties of undefined (reading 'name')
이 오류 너무 기분나쁨. 8001 이랑 연계되서 뜨는것 같은데
https://yamoo9.gitbook.io/typescript/types/object
     - (1). {{ account.name }} 에 ? 추가하기. / {{ account ?.name }}
     - (2). @Input() account: { name: string; status: string; } | undefined;

1-3). ERROR Error: Cannot find control with name: '0'
- formArray 문제같음
https://github.com/angular/angular/issues/9251

- 지금 듣는 강의 angular 버전이 8 이전이라. 똑같이 따라쳐도 문제가 발생하네.

- formControl 부분. 

-> 초반에 했던 실수인데. 데이터가 처리되기 전에 사용하려고 했기 때문에 발생했던 오류 (해결)

 

 


 

'프로그래밍 기초 > 오류코드 정리' 카테고리의 다른 글

기타 오류 관련 (~2023.12.16)  (0) 2023.12.06
npm 설치 관련 오류  (0) 2022.10.05