pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

pm2 not updating NODE_ENV

Open saurav2501 opened this issue 8 years ago • 5 comments

I have set local and development NODE_ENV in pm2 config file. Initially I used local mode but when I tried to move from local to development mode using provided pm2 commands, it's not updating my NODE_ENV from local to development. I have tried following commands but none of them updated the NODE_ENV.

  1. pm2 restart app.json --env development
  2. pm2 reload app.json --env development
  3. pm2 reload app.json --update-env development
  4. pm2 restart app.json --update-env development

But while refreshing my page it's updating NODE_ENV. Kindly help through it may it's getting cached

saurav2501 avatar Jan 04 '18 10:01 saurav2501

--env and --update-env are two different flag that doesnt have the same behavior :

  • --env is used to tell pm2 to pickup the dev environment from the app.json
  • --update-env tell to the daemon to pickup the new environment sent by the CLI and inject it when restarting. So you need to do pm2 reload app.json --env development --update-env

vmarchaud avatar Jan 04 '18 12:01 vmarchaud

Thanks @vmarchaud for the reply. I have tried your given command but still it's not injecting development mode. This works only after refreshing the page and NODE_ENV changes from local to development. I think it's getting cached and not able to update the NODE_ENV while runnning the command.

saurav2501 avatar Jan 04 '18 12:01 saurav2501

What do you mean by refreshing the page ?

vmarchaud avatar Jan 04 '18 12:01 vmarchaud

My homepage which I get after starting my server

saurav2501 avatar Jan 04 '18 13:01 saurav2501

Then it might be indeed your browser that is caching the view

vmarchaud avatar Jan 04 '18 15:01 vmarchaud