How to Build Your First NodeJS Server with ExpressJS

Written by Mulhern | Published 2020/07/26
Tech Story Tags: expressjs | programming | nodejs | learning-to-code | web-development | backend | api | learn-to-code | web-monetization

TLDR Initialize the project: Create the home script, install the necessary dependencies, create the server and write the server file. Create the server for the first time: Write the server. Use the project's home script to create a home page and create a server. Create a server: Write a server file: Create a home script and write a server. Use the server to create the home and server. For more information about the project, visit http://://://www.com/pieriercognognogna.org/svsvsv.via the TL;DR App

Initialize the project:
npm init
Install the necessary dependencies:
npm install express http --save
Create the home script:
touch index.js
Install nodemon:
npm install nodemon -g
Write the server file:
let express = require('express')
let http = require('http')

// Initializes an express app.
let app = express()

// Gets the first route: '/'.
app.get('/', function(req, res) {
// Sends "HELLO WORLD"
    res.send("HELLO WORLD")
})

// Creates a new http server with app and listens on localhost:8080 in your browser.
http.createServer(app).listen('8080')

Written by Mulhern | Javascript Enthusiast - Find Angular Book Here: https://www.lulu.com/account/projects/7dqz7r.
Published by HackerNoon on 2020/07/26