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

5

7

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

Bioscope answered 15/3, 2022 at 22:5 Comment(2)
did you got that error when running npm run build or what?Metallic
I answered the quetion, you can check my answerBryantbryanty
B
22

The problem was resolved by executing this command :

npm uninstall @nestjs/config && npm install @nestjs/config
Bioscope answered 15/3, 2022 at 22:55 Comment(2)
time saving, thanksNowlin
worked on fedora 39 workstation LinuxFlash
B
7

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.

Brief answered 18/4, 2023 at 20:59 Comment(0)
B
1

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

Brahear answered 27/8, 2023 at 19:24 Comment(0)
L
0

I solved the problem by deleting node_modules folder and reinstalling everything

Lightproof answered 16/2 at 12:32 Comment(0)
A
0

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!

Acceptation answered 2/3 at 2:28 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Longhorn

© 2022 - 2024 — McMap. All rights reserved.