Complete the code to load environment variables from a .env file.
require('[1]').config();
The dotenv package loads environment variables from a .env file into process.env.
Complete the code to access the PORT environment variable with a default fallback.
const port = process.env.[1] || 3000;
process.env.PORT accesses the port number set in environment variables. If not set, it falls back to 3000.
Fix the error in the code to correctly load environment variables asynchronously.
import dotenv from '[1]'; await dotenv.config();
The dotenv package is imported to use its config() method for loading environment variables.
Fill both blanks to set a custom path for the .env file and load it.
dotenv.config({ path: [1] + '[2]' });Combining __dirname + '/configs/' with '.env' sets a custom path to the .env file.
Fill all three blanks to create a config object that reads NODE_ENV, sets a default, and exports it.
const config = {
env: process.env.[1] || '[2]',
port: process.env.PORT || [3]
};
export default config;This config object reads NODE_ENV with a default of 'development' and sets port with a default of 3000.