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 Middleware Basics

mikkel pohjola
mikkel pohjola
1,966 Points

I cant use localhost:3000

what editor do you use in this video, because i cant get localhost:3000 to work

Nick Wilson
Nick Wilson
5,060 Points

He is running a local server on his browser. You do this by downloading WAMP for Windows, or MAMP for Mac. You couldn't connect to localhost:3000 because you don't have a server set up connected to port 3000.

Download MAMP or WAMP and read some documentation on it.

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Hi Nick! Actually, Express creates its own server, so Apache (the "A" from the WAMP or MAMP stack) can't be used for this workshop. Please refer to my answer to this question for details on how to get up and running. :)

2 Answers

Joel Kraft
STAFF
Joel Kraft
Treehouse Guest Teacher

Hi Mikkel,

The text editor you use won't affect how your app is served (but the text editor I use in this workshop is Sublime Text).

To serve your app from localhost:3000:

  1. download & unzip the project files
  2. in your console, navigate to the folder for the video project you want to serve
  3. run "npm i && nodemon"

Make sure you have node and npm installed. Here's a list of guides for installing those. You'll also want to have nodemon installed. While nodemon isn't strictly required, it is recommended.

Have you been through the Express Basics course? If not, I would strongly recommend taking that before this workshop. Everything in this workshop will make a lot more sense after that course.

Let me know if you have more questions! Thanks, Joel

Mike Hatch
Mike Hatch
14,940 Points

Thanks Joel for the npm i command. I was trying to figure out how to get those node_modules installed. I don't recall learning this command from the Express Basics course. We installed nodemon with npm install -g nodemon and used nodemon to run it. I don't recall how we got them in the Flashcards app.

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Mike Hatch,

$ npm i

is a shortcut for

$ npm install

which we used in Express Basics to install Express.js. For more information about installing and working with node's package manager, check out npm Basics.

You can install node packages in a number of ways, including globally, as people often do with nodemon. That course covers global installation generally, too. Hope that helps clarify!

Mike Hatch
Mike Hatch
14,940 Points

Thanks Joel. I've since used npm install quite a lot since then. Funny how looking back it sounds complicated, but when you keep using it you see how simple it is.

I cannot use localhost:3000

I downloaded the project files and extracted all. I downloaded npm and nodemon and I did all the tests and they are installed. I created the hello.js and tested it in powershell and it worked and confirmed node was installed. I also downloaded WAMP. I restarted my computer and now I still cannot access localhost:3000......

whenever I go to the terminal in VS in the files I downloaded and type nodemon it does not "start" anything it says :

C:\Users\bri15_000\Downloads\javascript_understanding_express_middleware>nodemon Usage: nodemon [nodemon options] [script.js] [args]

See "nodemon --help" for more.

... I tried typing nodemon in command prompt and power shell as well...

please help

mikkel pohjola
mikkel pohjola
1,966 Points

hi that is what i was missing i need wamp/mamp server ofcourse, thanks for the help to your all :)

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Actually, a WAMP or MAMP setup will not help you serve this project. See my comment to Nick. Installing WAMP or MAMP shouldn't hurt you (although it will add overhead to your computer's resources), but it has nothing to do with Node or Express. Good luck!