Cannot find module 'passport' or its corresponding type declarations

PrabodhanaJ picture PrabodhanaJ · Jun 29, 2020 · Viewed 8k times · Source

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?

Answer

dreamHatX picture dreamHatX · Aug 28, 2020

I had the same problem. But I did a rebuild and everything worked. Removed the dist folder and then start again

rm -r dist
npm run start:dev