All Tutorials

Your One-Stop Destination for Learning and Growth

Getting Started with Web Application Development: A Tutorial by Samantha Gibson - Part 1: Installation

Welcome to the first part of this tutorial series on getting started with web application development! In this post, we'll be going through the installation process as guided by web development expert and instructor, Samantha Gibson.

Prerequisites

Before you start, ensure that you have the following tools installed:

  1. A text editor: We recommend using Visual Studio Code or Sublime Text. Both are free and open-source.
  2. Node.js: Node.js is a cross-platform JavaScript runtime environment. Download it from the official website and follow the installation instructions for your operating system.
  3. git: Git is a version control system that helps you manage and track changes to source code. If you haven't installed it yet, download it from the official website and follow the installation instructions.

Installing Express.js

Express.js is a popular and lightweight web application framework for Node.js. Let's install it using npm (Node Package Manager). Open your terminal or command prompt, navigate to a new directory for this project, and run:

npm init -y
npm install express

The npm init -y command initializes a new Node.js project with default settings. The npm install express command installs Express.js as a dependency.

Setting up the Application

Create a new file called app.js in your project directory and add the following code:

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

This code sets up a basic Express application with a single route that returns "Hello World!" when the root path ("/") is requested. The server also logs a message when it starts.

Running the Application

To start your new Express application, run:

node app.js

If everything was installed correctly, you should now see the following output in your terminal or command prompt:

Server is running on port 3000

Visit http://localhost:3000 in your web browser to verify that the application is working as expected.

In the next part of this tutorial series, we'll be exploring how to create dynamic routes and serve static files using Express.js! Stay tuned!

Published July, 2017