Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5058

Node.js - Config can't load environment variable after setting it using terminal (Windows10)

$
0
0

I am trying to set an environment variable from terminal to use it in my node.js code. Using config package, I created config folder in the root dir. Inside this folder I created two files:

default.json

{
    "database": {
        "mongo_url": "mongodb://localhost:27017/",
        "db_name": "my_database",
        "user_collection": "users",
        "cats_collection": "cats"
    },
    "server": {
        "port": "3300"
    },
    "jwtSecret": ""
}

custom-environment-variables.json

{
    "jwtSecret": "myApp_jwtSecret"
}

Then I set myApp_jwtSecret from terminal like this

setx myApp_jwtSecret bacd

I double checked it's value using

$myApp_jwtSecret

Why does config.get("jwtSecret") still ""


Viewing all articles
Browse latest Browse all 5058


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>