even though I am using: require('dotenv').config() at the top of my modules, my process.env variables (set in my.env file) are undefined.
This, despite the fact that my IDE clearly is seeing them as defined bc it autofills the variable names as I type them out.
Very strange. Any thoughts?
require('dotenv').config(); let config = { userName: process.env.userName, password: process.env.password, server: process.env.server }
here's my.env file:
userName='myNmae'
password='myPassword'
server='myServer.com'
PORT=3001
For me they were undefined for 2 reasons:
VUE_APP_
prefixed to them, for Vue that seems to be necessary.Hope this helps some lost soul.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.