I am trying to use process.env in value of a key in ts. But I am not able to access process properties and its showing "Cannot find namespace 'prcoess'".
const MAIL_SETTINGS: {
service: 'gmail',
auth: {
user: prcoess.env.MAIL_EMAIL,
pass: prcoess.env.MAIL_PASSWORD,
},
}
i tried to make process as a global variable and used it in value but didnt work.
I think there is typo in your code. Also, a technical aspect regarding import is missing. Like this.
require('dotenv').config() // requiring dotenv module
console.log(process.env) // logging on screen to confirm
const MAIL_SETTINGS: {
service: 'gmail',
auth: {
user: process.env.MAIL_EMAIL, // use process.env
pass: process.env.MAIL_PASSWORD,
},
}
Also, for the .env file. It should be structured like this.
MAIL_EMAIL=test@test.com
MAIL_PASSWORD=test