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 Getting Started with Express Creating a Server in Express

Sean Flanagan
Sean Flanagan
33,235 Points

Cannot find module "express"

Hi.

I ran node app.js and got the above error message. I'd copy it in whole but the node.js command prompt's copy option is greyed out so I can't select it. I wish we could use Workspaces for this course.

I'd appreciate any help.

3 Answers

So, my initial thought is that the express module isn't installed either globally or for that project. Go to the root folder of the project (the flashcards folder in the video), and run the following:

npm install express --save

There should then be a node_modules folder beneath your project/the flashcards folder, with an express folder inside that.

Also make sure you're running node app.js from that same project folder.

Good luck!

Sean Flanagan
Sean Flanagan
33,235 Points

Yay! I did what you first suggested, i.e. type npm install express --save and then node app.js. In the browser address bar, I typed localhost:3000 and got a white screen with "Error" in the title tab, saying "Cannot GET /". It seems we're in business!

I upvoted your comment and gave it Best Answer. Thanks Iain! :-)

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Iain Simmons. I tried to cd into the flashcards folder but got this output:

The system cannot find the path specified.

I'm using the node.js command prompt, by the way.

Well it will be whatever folder has the package.json and similar files, it might be called something different.

Are you downloading the project files from here on Treehouse? Because if so, I think they have a folder for each video, sometimes before and after. So just go into that folder, and run npm install to install all the dependencies.

Or you could pick the appropriate folder, copy it wherever you like and rename it to flashcards if you want it to match the videos.