# How to set and get environment variables for Lambda functions (Node.js)

## How to set and get environment variables for Lambda functions (Node.js)

This is how to set environment variables for the Lambda function (Node.js).

Click on “Environment Variables” under the Lambda function to display the settings screen.

To retrieve the environment variables set by the Lambda function, retrieve them as follows

``process.env.NODE_ENV``

It is customary to start with NODE_. Also, environment variables are strings, even if they are numbers.

Here is an example

``````process.env.NODE_ENV = 1;
console.log(process.env.NODE_ENV);
console.log(typeof process.env.NODE_ENV);``````

The result will be STRING as follows

``````1
string``````
English

タイトルとURLをコピーしました