Re-login to a shell session, then set the default node version.
# nvm install 0.10
# nvm alias default 0.10
The node binaries should now be in the PATH for all users the next time you login to a shell session. NPM will install global things to the /usr/local/node prefix.
#!/bin/bash
NODE_VER=6.2.2
if [ ! -f ~/.nvm/nvm.sh ]; then
# May need to be updated with the latest nvm release
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
fi
source ~/.nvm/nvm.sh
if ! command -v node | grep -q $NODE_VER; then
echo "Node is not installed"
nvm install $NODE_VER
nvm alias default $NODE_VER
fi
对于我们的应用程序,我们需要在用户之间共享 pm2:
if ! command -v pm2 &>/dev/null; then
echo "pm2 not installed"
npm install -g pm2
fi
# Share pm2 configuration between users
alias pm2='env HOME=/opt/sora pm2'