From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext

Unlock this course with a free trial

Join today to access over 25,000 courses taught by industry experts.

Create and run a basic Express server

Create and run a basic Express server

- So now that we have our project all set up with all the NPM packages and stuff that it needs, the next thing we're going to do is set up and run a very simple server. As we go on, we'll add more and more functionality to this server, but it's good to have a place to start. So what we're going to do is create a new folder inside our project and we'll call it source, s-r-c. And this will hold all the actual source code for our server. So inside this folder, let's create another file and we'll call it server.js. And here's where we're actually going to write the code for our server. So setting up an express server is a pretty simple process with a few basic steps. The first thing we're going to do is use ES 6's new import syntax to import express. And that'll look something like this. We'll say import express from express. And now the way that we actually create an express server is simply by saying, let app = express called with two parentheses after it. This might not make a whole…

Contents