[Redis]TypeError: require(...) is not a function 혹은 TypeError: connectRedis is not a function

[Redis]TypeError: require(...) is not a function 혹은 TypeError: connectRedis is not a function

에러 상황

node js기반 웹 프레임워크 express js를 이용해 웹 개발 중 redis 사용하는 과정에 문제가 발생. 에러 메시지는 다음과 같습니다.

TypeError: require(...) is not a function

혹은

TypeError: connectRedis is not a function

해결

해당 오류는 모듈 버전 차이로 인해 생길 수 있는 확률이 높다고 합니다. 저의 경우 express js에서 redis와 연결하기 위해 사용되는 모듈인 ‘connect-redis’이 버전 7 이상이었습니다. 이를 버전 6으로 낮추면 해결될 가능성이 높아보여 해당 모듈을 삭제 후 재설치했습니다.

  1. connect-redis 버전 확인
    npm list connect-redis
    
  2. connect-redis 삭제
    npm uninstall connect-redis
    
  3. 버전 6 connect-redis 설치
    npm install connect-redis@6
    

위 과정을 통해 문제를 해결했습니다.

results matching ""

    No results matching ""