I'm trying to add Swagger to my Nestjs app. Module not found error is thrown when I'm trying to compile it. I use the same code from Nestjs documentation. This is my main.ts:
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const config = new DocumentBuilder()
.setTitle('Cats example')
.setDescription('The cats API description')
.setVersion('1.0')
.addTag('cats')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();
This is the error:
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module '@nestjs/core/router/route-path-factory'
Require stack:
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\node_modules\@nestjs\swagger\dist\swagger-explorer.js
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\node_modules\@nestjs\swagger\dist\swagger-scanner.js
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\node_modules\@nestjs\swagger\dist\swagger-module.js
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\node_modules\@nestjs\swagger\dist\index.js
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\node_modules\@nestjs\swagger\index.js
- D:\BK\solidity\MVPApp\blockchain\back-end-student-wallet-v2\dist\main.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
I'm using Node 14.15.1, @nestjs/swagger 5.0.0, swagger-ui-express: 4.1.6
Update latest version of @nestjs/platform-express, @nestjs/common,@nestjs/core (8.0.0) solve my problem. It seems like nestjs/cli uses previous version of nestjs