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.

"Advanced Node and Express - Set up a Template Engine" passes as correct despite wrong solution

See original GitHub issue

Describe your problem and how to reproduce it: When setting up Pug for the first time, even though I didn’t choose to render the index.pug page, but sent it (using app.sendFile), the FCC checker passed my solution as correct.

Code that wrongly passes tests:

app.route('/')
  .get((req, res) => {
    res.sendFile(process.cwd() + '/views/pug/index.pug');
  });

Actual solution:

app.route('/')
  .get((req, res) => {
    res.render(process.cwd() + '/views/pug/index.pug');
  });

This is especially confusing for a beginner as the boilerplate comes with res.sendFile as a default, simply changing the path results in the behavior shown in the screenshots below.

Add a Link to the page with the problem: https://www.freecodecamp.org/learn/information-security-and-quality-assurance/advanced-node-and-express/set-up-a-template-engine

Tell us about your browser and operating system:

  • Browser Name: Firefox
  • Browser Version: 74
  • Operating System: Linux Mint 19

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box): image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremyfielcommented, Apr 29, 2020

There is still an issue of the test not passing with correct solutions:

app.route('/').get((req, res) => {
    res.render(process.cwd() + '/views/pug/index');
  });

OR

app.route('/').get((req, res) => {
    res.render('./pug/index');
  });

hi @Sky020 we’ve submitted another pr to relax the regex a bit more. it’s pending review.

I believe the single period (relative path) the way you’ve written it doesn’t work in even the glitch app. It’s pointing at the wrong path. should be … or just /pug

0reactions
ShaunSHamiltoncommented, Apr 29, 2020

There is still an issue of the test not passing with correct solutions:

app.route('/').get((req, res) => {
    res.render(process.cwd() + '/views/pug/index');
  });

OR

app.route('/').get((req, res) => {
    res.render('./pug/index');
  });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Node and Express | FreeCodeCamp - YouTube
00:00 Intro ; 00:44 Set up a Template Engine ; 01:58 Use a Template Engine's Powers ; 02:44 Set up Passport ; 05:29...
Read more >
Set up a Template Engine - Advanced Node and Express
In this tutorial we set up a template engine called Pug. This is one part of many making up the Advanced Node and...
Read more >
Advanced Node and Express - Set up a Template Engine help ...
Hi. I'm not sure where you're at with the exercise. I hope you were able to successfully complete it and move forward.
Read more >
Node.js best practices list (July 2021) - DEV Community ‍ ‍
TL;DR: A perfect and flawless configuration setup should ensure (a) ... Though ESLint can automatically fix code styles, other tools like ...
Read more >
Using Node.js + Express without template engine
From what I have researched, you do not need a templating engine to use Node.js + Express. But you do need to set...
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