typescriptjwtnestjsnestjs-passportnestjs-jwt

Cannot find module 'passport' or its corresponding type declarations


I am using @nestjs/passport. After running npm run start:dev I got an error, but the editor doesn't show an error

node_modules/@nestjs/passport/dist/passport/passport.serializer.d.ts:1:27 - error TS2307: Cannot find module 'passport' or its corresponding type declarations.

1 import * as passport from 'passport';

Input Code:

import { PassportModule } from '@nestjs/passport';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { UserRepository } from './user.repository';
import { JwtModule } from '@nestjs/jwt';


@Module({
  imports:[
    PassportModule.register({defaultStrategy:'jwt'}),
    JwtModule.register({
      secret: 'topSecret51',
      signOptions:{
        expiresIn:3600,
      },
    }),
    TypeOrmModule.forFeature([UserRepository]),
  ],
  controllers: [AuthController],
  providers: [AuthService],
})
export class AuthModule {}

Any idea what the problem could be?


Solution

  • this error occurs due to the node version. if you got this, update node version and reinstall passport module using npm i --save @nestjs/passport passport