When i have written code for whatsapp boat using twilio module i get error in .env file
I have file structure like below:
/whatsappboatdemo
| app.js
| sendmsg.js
| .env
| package.json
And i have require dotenv like this in app.js file and sendmsg.js:
require('dotenv').config();
.env file content:
PORT=5000
TWILIO_ACCOUNT_SID=******************************
So when i run node app.js it gives undefined for process.env.PORT.
I have tried with different file structure but i don't get idea so please help me in this , thanks in advance :)
It is really hard to debug your issue with what you provided. I would advise to check 3 things as these are common errors:
Check if the format of the .env file is correct:
i.e.: PORT=9000 without any quotes etc.
Log the require call:
console.log(require('dotenv').config())
Try to set the path manually and check if it works:
require('dotenv').config({path: __dirname + '/.env'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With