npm i
ENV_FILE=.env.dev node test.js
ENV_FILE=.env.prod node test.js
Last active
October 7, 2022 14:59
-
-
Save jujhars13/6b7e95a71e5e70816f04ee090ce8e49b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MY_NAME=nitish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MY_NAME=sophie |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "nitish", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"dotenv": "^16.0.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config({ | |
path: process.env?.ENV_FILE ? process.env?.ENV_FILE : '.env.dev' | |
}); | |
console.log (process.env?.MY_NAME); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment