Search code examples
node.jsenvironment-variablesstatic-analysis

Does nodejs give you a way to see all environment variables that it can use?


When I start to use an existing app/codebase, I'm often confounded by which environment variables it's wired to use. People make bad docs, and I hate hunting and being disoriented by this part of app dev.

Is there a way to see all environment variables that it can use? Like an npm run... task that lists them all statically?


Solution

  • Node.js can basically use all of your systems environment variables. try console.log(process.env) and you'll find that all environment variables that you've declared, even before starting your node app are showing.

    You can also create new environment variables through node, by doing process.env.MY_ENVIRONMENT_VARIABLE = 'hello'. So i guess searching process.env through the whole project should list all env variables being accessed and created inside node.