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

Hi,

I have node installed via nvm (https://github.com/creationix/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.sh" ] && . "$NVM_DIR/nvm.sh"  # 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: http://pm2.keymetrics.io/docs/usage/deployment/ . 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?

Regards,

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;;
esac

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

More Issues: