Skip to content

Instantly share code, notes, and snippets.

@the-vampiire
Last active May 24, 2019 05:44
Show Gist options
  • Select an option

  • Save the-vampiire/3fe78764f70080bc2736f6820862ba34 to your computer and use it in GitHub Desktop.

Select an option

Save the-vampiire/3fe78764f70080bc2736f6820862ba34 to your computer and use it in GitHub Desktop.
set node process.env variables without dependencies
PORT=8008
OTHER_VAR='stuff'
{
"start": "env $(cat .env) node file-name.js",
}
@the-vampiire
Copy link
Author

the-vampiire commented May 24, 2019

this approach does not require dot-env or any other 3rd party node dependency.

here is an example for use with nodemon:

.env

PORT=8008
OTHER='stuff'

package.json

{
  ...
  "dev": "env $(cat .env) nodemon app.js",
  ...
}

usage

$ npm run dev

in the app

console.log(process.env.PORT, process.env.OTHER); // 8008 'stuff'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment