Код main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api')
await app.listen(3000);
}
bootstrap();
Код app.module.ts:
import { Module } from '@nestjs/common';
import {ConfigModule} from "@nestjs/config";
import {MongooseModule} from "@nestjs/mongoose";
import {ServeStaticModule} from "@nestjs/serve-static";
import { AuthModule } from './auth/auth.module';
import * as path from "path";
@Module({
imports: [
ConfigModule.forRoot({
envFilePath: `./config/.${process.env.NODE_ENV}.env`
}),
MongooseModule.forRoot(`${process.env.DATABASE_URL}/${process.env.DB}`),
ServeStaticModule.forRoot({
rootPath: path.resolve( __dirname, 'static'),
}),
AuthModule,
],
controllers: [],
providers: [],
})
export class AppModule {}
Код auth.module.ts (auth.controller.ts и auth.service.ts пустые):
import { Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
@Module({
controllers: [AuthController],
providers: [AuthService]
})
export class AuthModule {}
Ругается на последнюю строку в auth.module.ts:
export class AuthModule {}
, ошибка:
TS2300: Duplicate identifier 'AuthModule'.
. Как исправить?