I'm currently running a node application on an EC2 Instance Linux using PM2 to manage and it keeps crashing, throwing an error that reads Username is required
.
This username is being fed from process.env.USERNAME
that I set using dotenv for development.
So far using AWS shell I have tried to pass the env variable in the following paths:
/etc/profile
/etc/bashrc
/etc/profile.d
~/.bash_profile
~/.bashrc
The variables were put in this form: export VARIABLE_KEY=VALUE
I also tried to put the variables inside /etc/environment
. None of which is making it work.
I restarted the server each time, logged out, and logged back in.
The way I solved it was to restart pm2 using pm2 restart --update-env
. When you first run pm2 start
, it caches the env variables, so I needed to restart it to add the newly created env variables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.