paint-brush
How to Build Your First NodeJS Server with ExpressJSby@Mulhern
372 reads
372 reads

How to Build Your First NodeJS Server with ExpressJS

by BrendanJuly 26th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

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.
featured image - How to Build Your First NodeJS Server with ExpressJS
Brendan HackerNoon profile picture

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')