Install the Upstream version of Node. js on Ubuntu
Install the Upstream version of Node. js on Ubuntu
Node. js is a software platform that can be used to quickly develop and build scalable Web applications. Node. js uses JavaScript as its scripting language and achieves high throughput through non-blocking I/O and single-thread event loops.
Node. js contains a built-in HTTP server library that allows it to run directly on a Web server without using external software, such as Apache or Nginx, in addition, more control can be provided when the Web server is running.
To install Node. js on the Ubuntu server, you must first update the system. In fact, before installing any software package, make sure that the software warehouse is up-to-date:
# sudo apt-get update
Once the system is updated, you need to install the build-Essential Package. This package contains the base library for building the Debian software package.
# sudo apt-get install build-essential
You also need to install the curl tool. Curl is a library and can be used for HTTP requests in the command line.
# sudo apt-get install curl
After installing curl, you must install all the packages required by Node. js. There are multiple methods to install Node. js. The simplest method is to execute:
# sudo apt-get install Nodejs
However, the latest Node. js version may not be added to the Ubuntu standard library. To ensure that the latest version is used, we should download the source code, compile and install it.
First, add the environment variable to the. bashrc configuration file:
# echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc# . ~/.bashrc
Then, create the directory required for the installation process:
# mkdir ~/{local,node-latest-install}
Then, go to the latest installation directory, use curl to download the Node. js document, and decompress it with the tar tool.
# cd ~/node-latest-install# curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
Next, set the parameters to install Node. js for the current user and run:
# ./configure --prefix=~/local# make install
Once Node. js is installed, install the Node. js Package Manager NPM, which is also the official Software Package Manager of Node. js.
# curl https://npmjs.org/install.sh | sh
Check whether the installation is successful by checking the Node. js version. Execute:
# node -v
OK.