-
-
Save textbook/b304b63042110af535389e6b1068d592 to your computer and use it in GitHub Desktop.
This file contains 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
FOO=123 | |
BAR=hello, world! |
This file contains 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
import "dotenv/config"; | |
function main() { | |
const foo = process.env.FOO; | |
const bar = process.env.BAR; | |
if (!foo || !bar) { | |
throw new Error("missing FOO and/or BAR"); | |
} | |
console.log("foo", foo, "bar", bar); | |
} | |
main(); |
This file contains 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": "dotenv-es6", | |
"version": "0.1.0", | |
"description": "", | |
"main": "index.js", | |
"type": "module", | |
"scripts": { | |
"start": "node index.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "Jonathan Sharpe <[email protected]>", | |
"license": "ISC", | |
"dependencies": { | |
"dotenv": "^16.0.0" | |
} | |
} | |
This file contains 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
$ node -v | |
v16.14.2 | |
$ npm -v | |
8.5.0 | |
$ npm start | |
> [email protected] start | |
> node index.js | |
foo 123 bar hello, world! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment