Skip to content

NestJS Swagger Error: "Cannot find module '@nestjs/swagger'" #598

Answered by TatyOko28
Mercure28 asked this question in Q&A
Discussion options

You must be logged in to vote

This happens when Swagger is not installed.

Solution: Install Swagger module

npm install @nestjs/swagger swagger-ui-express

Then, set up Swagger in main.ts:

import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";

const config = new DocumentBuilder()
    .setTitle("API Docs")
    .setDescription("My API description")
    .setVersion("1.0")
    .build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("api", app, document);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mercure28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants