There are 2 ways to do this safely:
First you need to use the command line options when starting the application.
These parameters are then located in process.argv
So node myapp.js username password will give you:
process.argv[0]=node process.argv[1]=/.../myapp.js (absolute path) process.argv[2]=username process.argv[3]=password
Secondly, to set credentials as ENV variables. This is usually considered best practice, since only you have access to these variables.
You will need to set the variables using the export command, than you will get access to it in process.env
source share