So I have install npm config module.
I have trying to set a local variable that stores a secret/privateKey.
Tried setting an environment variable/private key using the following command
export VIDLY_JWTPRIVATEKEY=MYSECUREKEY
however it don't think It is being set as I get an error via
console.log("FATAL ERROR: JWTPRIVATEKEY is not defined");
This is how I am checking if the key is set..
index.js
if (!config.get("JWTPRIVATEKEY")) {
console.log("FATAL ERROR: JWTPRIVATEKEY is not defined");
// node environment variable. 1 (any other number exc. 0) is exit the app, 0 is success
process.exit(1);
}
userAuth.js I once again try to get the private, however its not set (?)
#code above
const token = jwt.sign({ _id: user._id }, config.get("JWTPRIVATEKEY"));
default.json (in config module folder)
{
"JWTPRIVATEKEY": ""
}
custom-environment-variables.json (in config folder)
{
"JWTPRIVATEKEY": "VIDLY_JWTPRIVATEKEY"
}
**
ERROR: "FATAL ERROR: JWTPRIVATEKEY is not defined"
**
What am I doing wrong?
./config/*.jsonalso if you want to use js export it likemodule.exports = {"JWTPRIVATEKEY": "VIDLY_JWTPRIVATEKEY"}- The docs are extensive github.com/lorenwest/node-config/wiki - Lawrence Cherone