Posts

Showing posts from January, 2022

Node Js Core Modules

 Node js is a javascript engine that allows to execute javascript. This engine comes with a set of core modules to implement basic functionalities. Here is a brief of  list of core modules: Console: The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

Node JS Environment Variables: Setting up Environment Variables in Node JS

è Environment Variable are access all over the application è These are like Global variables è We can use them in configurations è By default environment variables will be store in process.env è If we want to set up environment variables and use them we need to create one file under the main folder called .env è We can add environment variables in the .env file. è To access this values we need install dotenv package , This can be done with npm install dotenv statement è After installing page need to include it in file -> require(‘dotenv’).config(). Will load the dotenv package Example: In .env file you can add any constants, Below is the example constants I’m Using. USER_ID = 12 In app.js file, I’ll be using the above mentioned environment value require("dotenv").config(); console.log("welcome"); console.log(process.env.USER_ID);   OUTPUT: Welcome 12