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) Serving Static Files in Express Add Static to the Layout Template

Jack Hegarty
Jack Hegarty
9,381 Points

Created new git clone. When I start the node server I receive an error and it appears my old server is still running???

I messed up somewhere along the way and decided to clone Huston's git repo to a brand new folder on my machine.

When I go to run this new server via nodemon I receive this error:


module.js:338 throw err; ^ Error: Cannot find module 'express' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (C:\Users\jhegarty\desktop\expressproject\express-basics\src\app.js:3:15) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) [nodemon] app crashed - waiting for file changes before starting...


When I got to localhost:3000 - I can tell that it is serving files from my OLD project and I can make changes to my OLD file and they will showup. I CANNOT figure out how to kill the old node server so I can continue with my new clone.

If i go to my localhost:3000 with no servers running it should not serve me anything correct? How can I kill my old server so I can run my new one?

Jesus Mendoza
Jesus Mendoza
23,288 Points

That has nothing to do with git or github. Open the Task Manager and close all the open Windows Console (cmd) or restart your computer if you want

Also make sure you run

npm install

It seems like you haven't done this, so this error occurs..

1 Answer

Sara Greer
Sara Greer
16,032 Points

When you see Error: Cannot find module 'express', it means you have not installed the modules required for the app to run. It only lists the 'express' module in the error text because it is the first module called in the app.js file.

If a package.json file is present, you can simply type "npm install" into your console/terminal and hit enter. That will install all required modules and you can try starting your server again.