Wahéb
Wahéb

Reputation: 771

Module '"@nestjs/config"' has no exported member 'ConfigModule'

I'm using NestJS,I installed @nestjs/config module using the command :

npm i --save @nestjs/config 

I got this error : Module '"@nestjs/config"' has no exported member 'ConfigModule'

this is my code in app.module file :

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { UserModule } from './user/user.module';
import { BookmarkModule } from './bookmark/bookmark.module';
import { PrismaModule } from './prisma/prisma.module';
import { ConfigModule } from '@nestjs/config';

@Module({
  imports: [ConfigModule, AuthModule, UserModule, BookmarkModule, PrismaModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

PS : Node version : 17.6.0 / OS : Manjaro Linux

Upvotes: 8

Views: 16664

Answers (5)

Miguel Silva Rubio
Miguel Silva Rubio

Reputation: 1

i had this problem beacue i use this npm command: npm i nestjs/config, but, the correct command is npm i @nestjs/config, if you uninstall and install again the package the problem will be resolved!

Upvotes: 0

Mark
Mark

Reputation: 78

I solved the problem by deleting node_modules folder and reinstalling everything

Upvotes: 0

Samuel
Samuel

Reputation: 59

When installing ConfigModule, to make it detected, one should first stop the server, then install with "npm i --save @nestjs/config"

Upvotes: 1

Wuagliono
Wuagliono

Reputation: 402

If the problem persist after applying @Wahéb answer, try:

  • on Windows: Shift + Ctrl + p -> Restart TS server
  • on Mac: Cmd + Shift + p -> Restart TS server

After this, you should have ConfigModule imported correctly.

Upvotes: 9

Wahéb
Wahéb

Reputation: 771

The problem was resolved by executing this command :

npm uninstall @nestjs/config && npm install @nestjs/config

Upvotes: 24

Related Questions