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 (2015) The Request and Response Objects in Express Requests and the request object

Anthony Scott
PLUS
Anthony Scott
Courses Plus Student 9,001 Points

error when starting nodemon

I am trying to run nodemon on the code I just checked out from git on the express-basics Requests and request objects video. I have had a ton of trouble with this nodemon and node-inspector portion of the course.

When I run node --debug src/app.js, I get:

Debugger listening on [::]:5858
module.js:442
    throw err;
    ^

Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/antkn33/express-basics/src/app.js:3:15)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
[nodemon] app crashed - waiting for file changes before starting...

2 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

What is on code line 3, in app.js?

    at Object.<anonymous> (/Users/antkn33/express-basics/src/app.js:3:15)

I'm guessing it's

var express = require('express');

Are you sure it's been downloaded correctly? If yes, you should be able to find it in "node_modules"

Anthony Scott
PLUS
Anthony Scott
Courses Plus Student 9,001 Points

Yeah, I think after downloading the code I should have run npm install

Thomas Nilsen
Thomas Nilsen
14,957 Points

Yes. It's not common practice to push all of the node_modules to git.

What's more common is to add dependencies to package.json and node_modules to .gitignore, and run npm install to download the dependencies yourself.