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

Can't read custom environment variables in node using config.get()

$
0
0

I use config library to manage my configuration files in node application.

I have export my custom env variable in terminal by export app_password=12345

and map it into the custom-environment-variable.json file by

{"mail": {"password": "app_password"   }}

when I use config.get('mail.password') in my index.js file (root module) .

I got error: Configuration property "mail.password" is not defined, detail in below:

/Users/tzhong/Documents/vidly- backend/node_modules/config/lib/config.js:203throw new Error('Configuration property "'+ property +'" is not defined');^Error: Configuration property "mail.password" is not defined    at Config.get (/Users/tzhong/Documents/vidly-  backend/node_modules/config/lib/config.js:203:11)

I have use console.log(process.env.app_password) to check if my custom env variable is there, and the app_password show in the terminal.

 Vidly evn is : Vidly backend -- development Vidly mail server is : dev-mail-server Mail-password is : 12345 NODE_ENV is : undefined app: development Mongan enabled... Listenning 3000 port ...

I want to use console.log(config.get('mail.password')); to show my custom variable in terminal instead of console.log(process.env.app_password)Any suggestions?

Finally solve the problem :It's tiny mistake, in config library, the file's name for creating custom environment variable is strict, the file's name should be 'custom-environment-variables.json', I have a wrong spell on 'environment' , after all , thanks for people offer other available package


Viewing all articles
Browse latest Browse all 5049

Trending Articles



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