Show all ENV variables used by a pm2 process — NodeJS

There are multiple ways of setting environment variables, such as defining it in the bash profile on the host, part of a pm2 deployment file — ecosystem.js, .env file or, any other method you might use. Having said that, knowing which environment variables are set for the current process can be challenging. Besides, if we add the fact that pm2 expects an explicit flag --update-env to the restart/reload command in order to reload environment variables, it becomes hard to be sure about the current env variables state.

Luckily, pm2 has a command that does just that. The pm2 env id will show all the environment variables loaded to the pm2 process with the specified id.

list of pm2 enviroment variables for the id 1

The id can be obtained by running the pm2 l command.

pm2 listing running processes to obtain id

--

--