[NodeJS] --env-file=.env

Normally you need to put

require("dotenv").config()
console.log(process.env.TEST)

to access env vars

 

WIth --node-fileflag you don't need to do that anymore

node --env-file=.env f.js

Then you can access the env directly in code

console.log(process.env.TEST)

 

posted @ 2024-01-22 14:25  Zhentiw  阅读(27)  评论(0编辑  收藏  举报