

With this setup, you get for example: which node nvmrc file to indicate the node version required for a given project: We can easily switch node versions with: nvm install 0.9.0 Is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communitiesĭownloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you That works, but I prefer to remove the auto-added one and add my own: f="$HOME/.nvm/nvm.sh"Īllows you to use multiple versions of Node and without sudo Since the sourcing has to be done for every new shell, the install script hacks adds some auto sourcing to the end of your. Now test it out with a dummy package: npm install -global vaca NVM installs both the latest stable node and npm for you curl | sh Other versions can also be gotten with a simple change to the repo URL - consult documentation for details. This is for the latest (at time of writing) Nodejs version 7. Sudo apt-add-repository "deb $(lsb_release -sc) main"Īnd here's the "post deprecation of apt-key way" of doing the same thing: curl | gpg -dearmor | sudo tee /etc/apt/keyrings/nodesource.gpgĮcho "deb $(lsb_release -sc) main" | sudo tee /etc/apt//nodejs.list

Generally speaking, loading arbitrary data from a URL into a root shell session is not a good idea and I wish people would stop peddling it as a solution for everything - "Please just run this script I'm sending you, and also while we're at it - I have a bridge you'd probably be interested in purchasing".Īs an alternative, here's the "Ubuntu Way" of doing the same, where you can see how the system is being updated and know what repositories and what keys are added to your system configuration: curl | sudo apt-key add.
