When I run my nodejs application on my Ubuntu Linux server using node server.js
it works correctly, and outputs the value of the environment variable $db
using process.env.db.
However, the app breaks when running sudo pm2 start server.js
, seeing the environment variable as undefined.
I've tried adding the variable in the following files:
- etc/environment:
db="hello"
- ~/.ssh/environment :
db="hello"
- ~/.bashrc :
export db="hello"
I've also rebooted and run source ~/.bashrc
to ensure the variable is available.
I think I've tried everything mentioned here, I don't know what else to do: