so my project directory is as follows:
project-name/
├── src/
| └── ...
├── public/
| ├── images/
| | └── ...
| ├── scripts/
| | └── ...
| └── styles/
| └── style.css
└── views/
└── index.hbs
main.ts:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.useStaticAssets(join(__dirname, '..', 'public'));
app.setViewEngine('hbs');
app.setBaseViewsDir(join(__dirname, '..', 'views'));
await app.listen(3000);
}
bootstrap();
app.controller.ts:
import { Controller, Get, Render } from '@nestjs/common';
@Controller()
export class AppController {
@Get()
@Render('index')
getHello() {
const data = {
title: 'My HTML and CSS Application',
message: 'Welcome to my application!',
};
return data;
}
}
I keep getting the error 'cannot find views directory inside dist'. The views is not inside dist, I know it's supposed to compile upon running 'npm run start' but it does not transfer. Here is the full traceback:
[Nest] 8324 - 03/08/2023, 16:07:25 ERROR [ExceptionsHandler] Failed to lookup view "index" in views directory "C:\Users\Aleksa Hadzic\OneDrive\Documents\importante\jadore\dist\views"