In the previous article, I described the correct posture for installing Nodejs in Windows, and we continue to look at installing and configuring Nodejs on Linux.
To stay consistent, here are three ways to
First method: Download and install via official website
https://nodejs.org/en/download/
The problem with this approach is that we need to find the page ourselves, find the link, and then download
Second method: Install using the APT tool
By default, only older versions are available in APT's source (note that you need to apt-get update first)
For example, if you run Apt-get install Nodejs, after you install, you need to view the version with NODEJS-V (note, not node-v)
This is obviously not a very pleasing thing (version old, and use the same way)
It is puzzling that another package, nodejs-legacy, is installed, the version number is also 0.10.25, but the mode of operation is node, not Nodejs
And Nodejs-dev, using the same way as Nodejs is the same, the version is 0.10.25
So the key problem is that the source of apt does not have the latest Nodejs the package, so what to do?
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions provides a workaround here, Node itself provides the source
If you are installing the 5.x version, you can run the following two lines of command
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -sudo apt-get install -y nodejs
Third method: Install and manage with NVM
The way to install NVM in Ubuntu is a bit special, you need to download the source code, and then run install.sh
You can use the following command to complete the latest version of the installation (note that GitHub ' above installation instructions are 0.31 this version, but I think it is best to not rely on this specific version number, so a slight modification, you can install the latest version each time)
git clone https://github.com/chenxizhang/nvm.git &&./nvm/install.sh &&. ~/.nvm/nvm.sh && RM–RF./NVM
Summarize:
For now, I'm still recommending a third approach. Of course, I would prefer apt tools to be more easily installed to the latest version.
Http://www.cnblogs.com/chenxizhang/p/5222918.html
Install Nodejs in the correct posture on Linux (Ubuntu server)