2 Minute HTTP server using Express in Node.js

I covered setting up a simple HTTP server using Node.js previously, but that was using the package “http-server” for serving files.

Today I hit the point of needing to write server-side code, so my approach had to change.

Follow these steps to get up and running asap:

  1. Install Node.js if you haven’t already
  2. Open your shell of choice (Terminal, Bash, Command Prompt, etc.)
  3. “cd” to your Project folder
  4. If you don’t have a “package.json” file, run “npm init” and mash Enter
  5. Run “npm install express –save” (dash dash save, sorry for WordPress formatting)
  6. Copy and paste the code below into a new file “server.js”
  7. Run “node server.js”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.