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 trialAva Jones
10,679 PointsGetting throw err when running program
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.
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: [] }
1 Answer
Travis Alstrand
Treehouse Project ReviewerHi Ava Jones !
In your terminal, have you changed directories to the root of your project before running node app.js
?
avajones@Avas-MBP Personal %
This makes me think maybe you're trying to start your app from a different location and it's not being able to find app.js
from your current directory.
You may need to cd
change directories until your terminal is "located" at the root folder of your project.
This video may help out if this is the case.
Ava Jones
10,679 PointsAva Jones
10,679 PointsThank you so much! I have been trying to figure this out for a month!
Travis Alstrand
Treehouse Project ReviewerTravis Alstrand
Treehouse Project ReviewerOh good! I'm glad you got it figured out! 😃