hanki.dev

Specify env vars from command line

I used to use dotenv to specify environment variables when running my Telegram bots locally for developing. It works, but today I learned that you can specify env vars when running the app from command line!

FOO=bar node index.js

This is cool especially if you set a script which starts your app using dev tokens. Using this you can get rid of one extra dependency.

"scripts": {
    "run-dev": "BOT_TOKEN=123456 node index.js"
},

Needles to say, production secrets shouldn't be stored in plaintext like this :)


✌🏼 Like my content? Subscribe via RSS feed.

#javascript #terminal