// Set an environment variable
process.env.API_KEY = 'your-api-key';
// Access and log the environment variable
console.log('API Key:', process.env.API_KEY);
code
Set and Access Environment Variable
This Node.js code sets an environment variable (API_KEY) using process.env and then logs the value of the environment variable. The comments provide explanations for each part of the code.
Node.js
Environment Variable
process.env