DEV Community

loizenai
loizenai

Posted on

How to setup Node/Express development environment

https://grokonez.com/node-js/how-to-setup-node-express-development-environment

How to setup Node/Express development environment

In the tutorial, we will show you how to setup Node/Express development environment that includes installation of Nodejs, NPM package, and 'Express Application Generator' optionally.

Installing Node

download nodejs - LTS version

Double-clicking on the downloaded file and following the installation prompts:

install nodejs

Testing your Nodejs and NPM installation:


>node -v
v8.11.1

>npm -v
5.6.0

Create a 'helloworld.js', use 'http' module to create a Nodejs server createServer().


//Load HTTP module
var http = require("http");

//Create HTTP server and listen on port 8000 for requests
http.createServer(function (request, response) {

   // Set the response HTTP header with HTTP status and Content type
   response.writeHead(200, {'Content-Type': 'text/plain'});
   
   // Send the response body "Hello World"
   response.end('Hello World\n');
}).listen(8000);

// Print URL for accessing server
console.log('Server running at http://127.0.0.1:8000/')

Start the server:

More at:

https://grokonez.com/node-js/how-to-setup-node-express-development-environment

Top comments (0)