beeimp
BeeImp
beeimp
전체 방문자
오늘
어제
  • 분류 전체보기 (110)
    • Program_Language (17)
      • Python (13)
      • Go (0)
      • JavaScript (4)
      • TypeScript (0)
      • Rust (0)
      • Solidity (0)
    • OS (8)
      • UNIX&LINUX (7)
      • Windows (0)
      • MacOS (1)
    • Front-End (19)
      • Svelte (19)
      • React (0)
    • Blockchain (6)
      • Bitcoin (0)
      • Ethereum (1)
      • Klaytn (0)
      • Project (5)
    • Data Structure&Algorithm (11)
      • Greedy (7)
      • Dynamic Programming (1)
      • Sort (0)
      • DFS & BFS (2)
      • Recursive (1)
    • Security (0)
      • SDP (0)
      • Authentication (0)
    • Network (3)
      • OpenWrt (0)
      • SDN&NFV (1)
    • Git (5)
    • IT_News (0)
    • 베타 학습단 (12)
      • SQL (12)
    • Project (1)
    • Issues (1)
    • Reviews (3)
    • I Learned (23)
      • TIL (23)
      • WIL (0)
    • Other (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • mysql
  • 블록체인
  • Docker
  • solidity
  • ubuntu
  • javascript
  • jenkins
  • typescript
  • Nest.js
  • Ethereum
  • 기초
  • blockchain
  • svelte
  • greedy
  • react
  • 탐욕법
  • sql
  • PYTHON
  • github
  • Git

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
beeimp

BeeImp

I Learned/TIL

[TIL] Nest 중복 호출 오류, Node process.cwd()와 __dirname의 차이

2022. 7. 13. 23:27

[TIL] Nest 중복 호출 오류, Node process.cwd()와 __dirname의 차이

날짜

  • 2022.07.13.

목표

  • Nest.js 학습

내용

Nest.js - @**InjectConnection** 중복 호출 오류

  • 오류 메세지

      ERROR [ExceptionHandler] Nest can't resolve dependencies of the AuthService (JwtService, ?, UsernameConnection). Please make sure that the argument UserConnection at index [1] is available in the AuthModule context.
    
      Potential solutions:
      - If UserConnection is a provider, is it part of the current AuthModule?
      - If UserConnection is exported from a separate @Module, is that module imported within AuthModule?
        @Module({
          imports: [ /* the Module containing UserConnection */ ]
        })
  • 원인

    • @**InjectConnection** 가 두번 선언되어서 오류 발생

      export class AuthService {
      constructor(
        private jwtService: JwtService,
        **@InjectConnection(User.name) private userModel: Model<User>,
        @InjectConnection(Username.name) private usernameModel: Model<Username>,**
      ) {}
        ...
      }
  • 해결

      export class AuthService {
          userModel: Model<UserDocument>;
        usernameModel: Model<UsernameDocument>;
        constructor(
          private jwtService: JwtService,
              **@InjectConnection() private readonly mongooseConnection: Connection,**
        ) {
              this.userModel = mongooseConnection.model(User.name);
          this.usernameModel = mongooseConnection.model(Username.name);
          }
          ...
      }

Node.js - process.cwd()와 __dirname의 차이

  • process.cwd()
    • 전역 객체의 메소드
    • 프로세스의 현재 작업 디렉토리를 문자열 값으로 리턴
  • __dirname
    • 현재 스크립트의 디렉토리 이름
    • 전역이 아니라 각 모듈에 대해 로컬을 문자열 값으로 리턴

결론

  • 오류의 원인을 정확히는 모르겠지만 잘 해결되었습니다.

'I Learned > TIL' 카테고리의 다른 글

[TIL] Mongo - import json file  (0) 2022.07.13
[TIL] Klip, EIP-5114  (0) 2022.07.10
[TIL] Nest.js 프로바이더와, React-Native 안드로이드 설정  (0) 2022.07.08
[TIL] Nest.js 컨트롤러 부분 학습  (0) 2022.07.06
[TIL] Nest.js Decoration  (0) 2022.07.05
    'I Learned/TIL' 카테고리의 다른 글
    • [TIL] Mongo - import json file
    • [TIL] Klip, EIP-5114
    • [TIL] Nest.js 프로바이더와, React-Native 안드로이드 설정
    • [TIL] Nest.js 컨트롤러 부분 학습

    티스토리툴바