Install Nodejs in the correct posture on Linux (Ubuntu server)

Source: Internet
Author: User

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.

Install Nodejs in the correct posture on Linux (Ubuntu server)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.