Environment variables allow us to manage the configuration of our applications separately from our base code. Separate configurations facilitate the implementation of our application in different environments (developmenttestproduction, etc).

Introduction

Implementing an application requires developers to pay attention and consideration to how it is configured. All applications are deployed in a development environment before being deployed in the production environment. We need to make sure that each environment is correctly configured, it could be disastrous if our production application were using our development database, to mention an example.

Many cloud service providers (HerokuAzureAWS, etc.) and in addition to the Node.js modules use environment variables. Providers, for example, will set a **PORT **variable that specifies which port the server must be located on for it to work properly. Modules can have different behaviors depending on the value of the **NODE_ENV **variable.

What are environment variables?

Environment variables are variables external to our application that reside in the operating system or in the container of the application that is running. An environment variable is simply a name assigned to a value.

By convention, the name is capitalized and the values are text strings, for example: PORT = 8080.

#javascript #nodejs #npm

Environment variables with Node.js
1.05 GEEK