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 trialDesmond Dallas
6,985 PointsExpress
Hi, im trying to run the local host but can get it to work.. I get the following error. Is there anyone that can help with this? Also in the app.js file the (req) are faded.
const app = express();
app.set('view engine', 'pug');
app.get('/', (req, res) => { res.render('index'); });
app.get('/cards', (req, res) => { res.render('card', { prompt: "who is buried in the tomb?" }); });
app.get('/hello', (req,res) => { res.render('hello'); });
app.listen(8080, () => { console.log('The application is running on localhost:3000!') });
This is what I get back when I run npm node app.js in terminal
Usage: npm <command>
where <command> is one of: access, adduser, audit, bin, bugs, c, cache, ci, cit, completion, config, create, ddp, dedupe, deprecate, dist-tag, docs, doctor, edit, explore, get, help, help-search, hook, i, init, install, install-test, it, link, list, ln, login, logout, ls, outdated, owner, pack, ping, prefix, profile, prune, publish, rb, rebuild, repo, restart, root, run, run-script, s, se, search, set, shrinkwrap, star, stars, start, stop, t, team, test, token, tst, un, uninstall, unpublish, unstar, up, update, v, version, view, whoami
npm <command> -h quick help on <command> npm -l display full usage info npm help <term> search for help on <term> npm help npm involved overview
Specify configs in the ini-formatted file: /Users/.......(name)......../.npmrc or on the command line via: npm <command> --key value Config info can be viewed via: npm help config
npm@6.2.0 /usr/local/lib/node_modules/npm
1 Answer
clickpass
23,992 PointsYou don't need to use "npm", instead try:
node app.js
Here's a great step by step tutorial about how to run a hello world node app:
https://expressjs.com/en/starter/hello-world.html
Hope that helps.