Setup Node.js development environment

  • 05 Mar, 2019

Setup a Node.js development environment is easy but when you need to work in a team, the best option is document all installation steps for everyone.

Every developer must use the same setup or things can be wrong. Bellow are small steps to setup a simple Node.js development environment

1 - Setup Node.js:  https://nodejs.org/en/ 2 - Setup VS Code: https://code.visualstudio.com/docs/setup/setup-overview 3 - Open VS Code create a folder and in this folder save an file as app.js 4 - Setup nodemon: Nodemon is a utility that will monitor for any changes in your source and automatically restart your server. Perfect for development. To install nodemom open a terminal window and go to the folder you created on step 3 and  type npm install nodemon –save-dev  on the terminal window . This will install nodemon  as development dependency 5 - change package.json to start the application using nodemon "name": "Node Development", "version": "1.0.0", "description": "Just another app", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon app.js" }, "author": "Kenio Carvalho", "license": "ISC", "devDependencies": { "nodemon": "^1.18.10" } } 5 - Run npm init on the folder and install Express (npm install express –save) //Production dependency

6 Add the code below to app.js and sav, just to test the environment:

const express = require ('express');

const app = express();

app.use('/',(req,res,next)=>{

 

res.send('<h1>Hello from Expres</h1>')

});

app.listen(3000)

7 run npm start on the terminal

open the url localhost:3000 and you will se the page.

Related Posts

Apple Is Trying to Kill Web Technology

  • 06 Dec, 2020

The programming languages used to build the web often find their way into apps, too. That’s largely due to software that allows developers to “reuse” the code they write for the web in products they b

Apple Is Trying to Kill Web TechnologyRead More

Secure Nginx server with LetsEncrypt

  • 12 Jun, 2020

You need A Fully Qualified Domain Name (FQDN) pointing to a dedicated IP address of the webserver. This needs to be configured by your DNS administrator or provider. 1 - Install Certbot in Centos 8

Secure Nginx server with LetsEncryptRead More

Node-red. & NGINX on Centos 8

  • 11 Jun, 2020

I am creating a server (Centos 8) to develop a system that will use an application using REACT as a front end to show data from different sensors.I will use NGINX as a webserver and Node-red as a back

Node-red. & NGINX on Centos 8Read More