인프런 커뮤니티 질문&답변
TypeError: Cannot read property 'passport' of undefined
작성
·
743
0
강사님 소스랑 똑같이 따라쳤는데
제목과 같은 에러가 납니다.
TypeError: Cannot read property 'passport' of undefined
at SessionStrategy.authenticate (D:\z3-develope\slack-socket\backend\node_modules\passport\lib\strategies\session.js:51:18)
at attempt (D:\z3-develope\slack-socket\backend\node_modules\passport\lib\middleware\authenticate.js:360:16)
at authenticate (D:\z3-develope\slack-socket\backend\node_modules\passport\lib\middleware\authenticate.js:361:7)
at Layer.handle [as handle_request] (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:317:13)
at D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:284:7
at Function.process_params (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:335:12)
at next (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:275:10)
at initialize (D:\z3-develope\slack-socket\backend\node_modules\passport\lib\middleware\initialize.js:66:5)
at Layer.handle [as handle_request] (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\layer.js:95:5)
패스포트를 못읽어오는거 같은데
네스트 버그인가요? 저와같은 에러 나오시는분 계신가요?
이게 처음부터 이 에러가 아니라 아마, 저 에러로 인해서
UnhandledPromiseRejectionWarning: TypeError: exception.getStatus is not a function
at HttpExceptionFilter.catch (D:\z3-develope\slack-socket\backend\dist\main.js:2211:34)
at ExceptionsHandler.invokeCustomFilters (D:\z3-develope\slack-socket\backend\node_modules\@nestjs\core\exceptions\exceptions-handler.js:33:26)
at ExceptionsHandler.next (D:\z3-develope\slack-socket\backend\node_modules\@nestjs\core\exceptions\exceptions-handler.js:13:18)
at D:\z3-develope\slack-socket\backend\node_modules\@nestjs\core\router\router-proxy.js:24:35
at Layer.handle_error (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\layer.js:71:5)
at trim_prefix (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:315:13)
at D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:284:7
at Function.process_params (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:335:12)
at next (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\index.js:275:10)
at Layer.handle_error (D:\z3-develope\slack-socket\backend\node_modules\express\lib\router\layer.js:67:12)
이 에러가 나는데 에러이셉션에서 에러를 가로채올때
이 에러같은 경우에는 스테이스를 가져올 수 없기때문에 바로 위 에러가 먼저나오고, 이셉션에서 에러 찍으면 제일 위에 있는 에러가 나옵니다.
내일 다시 해볼생각이긴 하지만
혹시 먼저 경험해보신분 계시면 해결방법 공유 부탁드립니다.
퀴즈
NestJS에서 Guard의 주요 역할은 무엇인가요?
데이터 유효성 검사
서비스 로직 실행
예외 처리
권한 및 인증 확인
답변 4
0
main.ts에 아래 추가해주고 해결했습니다.
세션이 없어서 난 에러인데.. 신기하네요 다른분들은 괜찮았나요..??
0
음 아직 화면이 없어서 포스트맨으로 보냈는데
에러메세지로 보아서는 패스포트를 못읽어오는게 문제인것같기는 하지만...
완벽하게 따라치지 못했을 가능성도 충분하니 좀 더 알아보겠습니다.
0
이구요,
이런식으로 임포트했습니다.
main.ts 전체코드는
입니다.
package.json
0






아,
https://github.com/ZeroCho/sleact/blob/master/nest-typeorm/src/main.ts
있어야 합니다.