question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I need to use pug in my projects, and i have this problem:

renderRecibo = (req, res, next) =>{
    try{
      var options = { format: 'A4' };
      let html = pug.renderFile("../../views/recibo.pug"

If i use only Node, works, but in Nest no.

In main file of Nest, i have:

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

thanks for all help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
cdiazcommented, Jul 20, 2017

Hi @franciscoffavaro, i use Pug in this example and it works perfect

1reaction
franciscoffavarocommented, Jul 20, 2017

Hi @cdiaz, it’s the same code of i have in my app. The problem is, i have a method called renderRecido. I get a pug file and render to make a pdf file and show. But all time, the file path send me an error:

{ Error: ENOENT: no such file or directory, open '../../views/recibo.pug'
    at Error (native)
    at Object.fs.openSync (fs.js:641:18)
    at Object.fs.readFileSync (fs.js:509:33)
    at handleTemplateCache (/Users/franciscofavaro/Documents/Github/nest-backend/node_modules/pug/lib/index.js:215:37)
    at Object.exports.renderFile (/Users/franciscofavaro/Documents/Github/nest-backend/node_modules/pug/lib/index.js:428:10)
    at ImagesService.renderRecibo.e [as renderRecibo] (/Users/franciscofavaro/Documents/Github/nest-backend/src/modules/images/images.service.ts:31:22)
    at ImagesController.getRecibo (/Users/franciscofavaro/Documents/Github/nest-backend/src/modules/images/images.controller.ts:14:26)
    at e (/Users/franciscofavaro/Documents/Github/nest-backend/node_modules/@nestjs/core/router/router-proxy.js:7:33)
    at Layer.handle [as handle_request] (/Users/franciscofavaro/Documents/Github/nest-backend/node_modules/@nestjs/core/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/franciscofavaro/Documents/Github/nest-backend/node_modules/@nestjs/core/node_modules/express/lib/router/route.js:131:13)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '../../views/recibo.pug' }

Not found the file, but the path is right. I really don’t know whats happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set "basedir" option for Pug in NestJS - node.js - Stack Overflow
I'm trying to use pug ...
Read more >
Pug: Getting Started
The general rendering process of Pug is simple. pug.compile() will compile the Pug source code into a JavaScript function that takes a data...
Read more >
NestJS Crash Course 04 | MVC and server-side rendering ...
In this video we are going to reuse our NestJS Job Controller to list the job positions using MVC and server-side rendering with...
Read more >
MVC | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >
Pug - nestjs-i18n
To enable pug support make use of the viewEngine option inside your I18nModule . src/app.module.ts. I18nModule.forRoot({
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found