Reputation: 771
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
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
Reputation: 78
I solved the problem by deleting node_modules folder and reinstalling everything
Upvotes: 0
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
Reputation: 402
If the problem persist after applying @Wahéb answer, try:
Shift + Ctrl + p
-> Restart TS serverCmd + Shift + p
-> Restart TS serverAfter this, you should have ConfigModule
imported correctly.
Upvotes: 9
Reputation: 771
The problem was resolved by executing this command :
npm uninstall @nestjs/config && npm install @nestjs/config
Upvotes: 24