Skip to content

Pug template issue in Tsed 8 #3133

@jkokh

Description

@jkokh

Describe the bug

I'm struggling with migrating from Ts.ED 7 to Ts.ED 8.
The issue is I'm getting this error when configuring Pug template engine:

event: 'PLATFORM_VIEWS_ERROR',
message: 'Unable to configure the PlatformViews service on your environment.',
error: TypeError: Cannot read properties of undefined (reading 'render')
    at file:///Users/evgeny/Projects/orig/node_modules/@tsed/platform-express/lib/esm/components/PlatformExpress.js:174:54
    at Array.forEach (<anonymous>)
    at PlatformExpress.configureViewsEngine (file:///Users/evgeny/Projects/orig/node_modules/@tsed/platform-express/lib/esm/components/PlatformExpress.js:173:44)
    at async PlatformExpress.beforeLoadRoutes (file:///Users/evgeny/Projects/orig/node_modules/@tsed/platform-express/lib/esm/components/PlatformExpress.js:64:9)
    at async PlatformBuilder.runLifecycle (file:///Users/evgeny/Projects/orig/node_modules/@tsed/platform-http/lib/esm/common/builder/PlatformBuilder.js:145:9)
    at <anonymous> (/Users/evgeny/Projects/orig/src/index.ts:22:20)

Views config

views: {
  root: join(process.cwd(), "src/views"),
  viewEngine: "pug",
  extensions: {
    pug: 'pug'
  }
}

What I’ve checked:

  • pug is installed in node_modules
  • View files exist in the correct location (src/views)
  • @tsed/platform-express is correctly imported and loaded
  • Code worked fine on Ts.ED v7
  • Running in ESM mode with swc-node

Expected behavior

I expect .pug templates to be rendered using the @View() decorator or res.render(...), like:

@View("home.pug")
@Get("/")
get() {
  return { message: "Hello from Pug!" };
}

To Reproduce

  1. Create a new Ts.ED 8 project
  2. Install pug: npm install pug
  3. Configure views in Server.ts:
    views: {
      root: join(process.cwd(), "src/views"),
      viewEngine: "pug",
      extensions: { pug: "pug" }
    }
    

Expected behavior

Pug templates render

Code snippets

Repository URL example

No response

OS

Macos

Node version

22

Library version

8.14.1

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions