# process.env — Node.js

Source: https://www.geekswithgeeks.com/en/nodejs/node-process-env

> Read environment variables to configure your app per environment.

## Reading variables

`process.env` exposes environment variables as strings — always provide a fallback.

```javascript
const port = process.env.PORT || 3000;
const env = process.env.NODE_ENV || "development";

console.log(`Starting in ${env} mode on port ${port}`);
```

## Setting them

Set variables inline before the command, or export them for the session.

```bash
PORT=4000 NODE_ENV=production node server.js

# or
export NODE_ENV=production
node server.js
```
