Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 942
PrabodhanaJ Avatar asked Jun 29 '20 15:06

PrabodhanaJ


2 Answers

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
like image 72
dreamHatX Avatar answered Sep 20 '22 14:09

dreamHatX


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

like image 27
PrabodhanaJ Avatar answered Sep 19 '22 14:09

PrabodhanaJ