To update Node.js, you’ll need npm’s handy n module.
If nvm isn’t for you, a package manager is your next best bet. Update Node.js Using a Node Package Manager (npm) You can tell nvm which version to use in each new shell with nvm use #.#.# and set a default with alias: nvm alias default node. You can check what versions are currently installed on your server with nvm ls and see what is available to install from the public repository by using the nvm ls-remote command.ĭownload, compile, and install a new version of Node.js with nvm install #.#.#, obviously substituting the #s for the Node.js version you want. Once you’re set up with the latest version of nvm, installing updated distributions of Node.js is a breeze. The command will output the current nvm version if everything worked.
You’ll have to close and re-open the terminal first, but you can verify a successful installation by using command -v nvm. To update to the latest version of nvm, you can get the install script by using cURL: curl -o- | bash Run an update of nvm first, then get the latest packages of Node.js to update your web server environment: sudo apt-get update sudo apt-get install build-essential checkinstall libssl-dev
You’ll need a C++ compiler, as well as the build-essential, and the libssl-dev packages. Node Version Manager, or nvm, is far and away the best method for updating Node.js. Update Node.js Using Node Version Manager (nvm) This guide also includes instructions for updating Node.js through binary packages with version-specific references. If extenuating circumstances prevent you from using nvm, you can rely on the resources of Node Package Manager (npm). We value simplicity and effectiveness in systems administration and, for us, the easiest method is to use Node Version Manager (nvm).īefore you start, check which version of Node.js you’re currently using by running node -v in a command line terminal. The exact steps to updating Node.js on a Linux system can vary by distribution, but our recommended methods will work across most versions.