NestJS
Set up debugger in a NestJS project.
Last updated March 19, 2026
NestJS
This guide covers adding debugger to a NestJS project. The setup takes two steps.
| Feature | Support |
|---|---|
| Server console | Yes |
| Server errors | Yes |
| HTTP requests | Yes |
| Browser script injection | Manual |
Install
npm install -D @ephem-sh/debugger
1. Initialize and apply middleware
In your src/main.ts, call initDebugger and apply the middleware
via app.use():
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { initDebugger, DebuggerMiddleware } from '@ephem-sh/debugger/nest'
initDebugger({ port: 3000 })
async function bootstrap() {
const app = await NestFactory.create(AppModule)
const mw = new DebuggerMiddleware()
app.use((req, res, next) => mw.use(req, res, next))
await app.listen(3000)
}
bootstrap()
The middleware is applied at the Express layer (via app.use())
rather than via MiddlewareConsumer so it intercepts all requests
including /_/d.js and /_/d.
2. Add script tags
Add script tags before </body> in your HTML templates:
<script>window.__DEBUGGER_INGEST_URL__="/_/d";</script>
<script src="/_/d.js" defer></script>
Verify
npm run start:dev
npx dbg statuspnpm dlx dbg statusbun x dbg statusyarn dlx dbg statusnpx dbg browser consolepnpm dlx dbg browser consolebun x dbg browser consoleyarn dlx dbg browser consoleFull example
See the complete working example at examples/node/nest.



