Solvedpm2 pm2 deploy doesn't read neither ~/.profile nor ~/.bashrc


I have node installed via nvm ( This means, that each time I want to use my node, I need to have this lines executed:

export NVM_DIR="/home/eagle-eye/.nvm"
[ -s "$NVM_DIR/" ] && . "$NVM_DIR/"  # This loads nvm

This piece is stored in the ~/.profile , when I login using the terminal - it reads (sources) it automatically.
When pm2 deploy logs in - the file is not sourced, which leads to the fact, that I need to do the next:

"post-deploy" : ". ~/.profile ; npm install ; bower install ; pm2 startOrRestart ecosystem.json --env production"

And it's not a problem.

But, when I want to use the pm2 deploy production exec 'bower --version', it is an issue, because I do not want to type . ~/.profile each time.

I have tried to search if it's possible to integrate this default command somewhere in my ecosystem.json, however I haven't found the exact documentation of the options which could be present there. Only this article: . Is there a full list of the options available inside the ecosystem.json?

Is that possible to configure the default command to be executed right after the ssh connection? What are the other ways to make pm2 deploy production exec <cmd> work?


5 Answers

✔️Accepted Answer

Might be your .bashrc file contains lines like these
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;

That's why everything works when you put export NVM to the top of your file

More Issues: