Trickier than it seems.
Let's assume that you've already created an unprivileged user named myapp
. You should never run your Node.js applications as root!
Switch to the myapp
user, and do the following:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
(however, this will immediately run the nvm installer - you probably want to just download theinstall.sh
manually, and inspect it before running it)- Install the latest stable Node.js version:
nvm install stable