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 build to run on operating systems like Linux, Android, Windows, and macOS. See the full article here(https://onezero.medium.com/apple-is-trying-to-kill-web-technology-a274237c174d)

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 sudo curl -O https://dl.eff.org/certbot-auto chmod 0755 /usr/local/bin/certbot-auto 2 - Configure Nginx server\name on nginx.conf Edit nginx.conf an change the variable server\name to the same FQDN of your server for example: server\name www.mysphere.com.br; 3 - Run the certbot command: Execute sudo /usr/local/bin/certbot-auto --nginx and follow the instructions Test if your Nginx server using https://

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 end.In this first post I describe how to install NGINX. Install nginx package using the yum command on CentOS 8: sudo yum update sudo yum install nginx Update firewall settings and open TCP port 80 and 443. Run: sudo firewall-cmd --permanent --zone=public --add-service=https --add-service=http sudo firewall-cmd --reload Enable nginx service by running systemctl command so that it starts at server boot time: sudo systemctl enable nginx start the service, run: sudo systemctl start nginx

Node-red. & NGINX on Centos 8Read More