Node server with server.js

With this structure formed, we will start the creation of the server itself, which is the creation of a main JavaScript file.

The most common name used is server.js, but it is also very common to use the app.js name, especially in older versions.

Let's add this file to the root folder of the project and we will start with the basic server settings.

There are many ways to configure our server, and probably you'll find the best one for yourself. As we are still in the initial process, we keep only the basics.

Open your editor and type in the following code:

// Import the Modules installed to our server var express = require('express'); var bodyParser = require('body-parser'); // Start the Express web framework var app = express(); ...

Get Learning Single-page Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.