I have a Node.js API that stores environment variables in a file called config.env
.
When I am not using pm2, I launch the server with the following command: NODE_ENV=prod nodemon --env-file config.env server.js
. It works properly and I can access the environment variables.
I would like to have access to the environment variables when I start the server with pm2. I tried this command, but it doesn’t work: pm2 start server -- --env-file config.env
.