I am trying to use the dotenv
NPM package and it is not working for me. I have a file config/config.js
with the following content:
'use strict';
var dotenv = require('dotenv');
dotenv.load();
console.log('config');
I have another file .env
at the root of my application folder. I also have an environment variable TWILIO_ACCOUNT_SID
.
This is the process I go through while trying to use the environment variables in a certain function:
$ node
> require('./config/config.js');
config
{}
> process.env.TWILIO_ACCOUNT_SID
undefined
I defined the TWILIO_ACCOUNT_SID
in my .env file but as soon as I try to output the value in my console, I get an error stating that the variable is undefined.
I will be very grateful for any support in troubleshooting this issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…