Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5970

How do I set Linux environment variables so that pm2 can see them for node.js apps?

$
0
0

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:


Viewing all articles
Browse latest Browse all 5970

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>