Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Using Templates with Express Using Pug in Your Express App

Ava Jones
Ava Jones
10,723 Points

Getting throw error from running pug

I have been trying to figure this out for a while and I have even reset the course still don't understand.

app.js:

const express = require('express');

const app = express();

app.set('view engine', 'pug');

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

app.get('/morememe', (req, res) => {
    res.send("<h1>Hehe boi</h1>")
})
app.listen(3000, () => {
    console.log('The application is running on localhost:3000')
});

index.pug:

doctype html
html(lang="en")
  head
    title Speech to hippie
  body
    h1 Sup hippies, I got somethin to say.
    p I'm baby fam echo park green juice, direct trade slow-carb kickstarter skateboard bodega boys iPhone mumblecore gastropub chillwave raw denim next level. Irony offal photo booth, actually activated charcoal vinyl copper mug knausgaard plaid fixie umami four dollar toast polaroid. Occupy squid celiac air plant woke organic. Blue bottle trust fund fanny pack, etsy direct trade af master cleanse. Blue bottle aesthetic YOLO meggings cloud bread seitan enamel pin tilde chicharrones. Brooklyn chia austin venmo, adaptogen etsy green juice umami poke.

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hey there Ava Jones ! :wave:

It's a bit hard to tell from just looking at the code, as it indeed looks fine.

What is the error saying? Where are your pug files located within your project? Did you install the needed dependencies?

If you continue struggling with this, if this is in a Workspace you can create a snapshot and drop your link here, or if you can upload your code to a github repo that would be helpful as well.

I hope you get it figured out!

Ava Jones
Ava Jones
10,723 Points

The error is:

avajones@Avas-MBP Personal % node app.js node:internal/modules/cjs/loader:1051 throw err; ^

Error: Cannot find module '/Users/avajones/Personal/app.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15) at Module._load (node:internal/modules/cjs/loader:901:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }

Ava Jones
Ava Jones
10,723 Points

I reposted the question