https://www.vultr.com

The Everywhere Cloud

Deploy an instance.
Accelerate your application.


Installing Node.js on Linux


Node.js is a runtime environment that allows JavaScript to be executed directly on the operating system. This enables the use of JavaScript to develop server-side applications.

In some Linux distributions, the Node.js implementation may not be properly maintained and may lag from the releases of its official website. The following procedure shows how to manually acquire and install Node.js in order to have the most recent packages.

==========

1. Download the desired Node.js version.

1.1. Node.js x64 and other 64-bit Long-term Support (LTS)

user@host: $ wget https://nodejs.org/dist/v[ersionNum]/node-v[ersionNum]-linux-[CPU64].tar.xz
user@host: $ tar -xf node-v[ersionNum]-linux-[CPU64].tar.xz
user@host: $ cd node-v[ersionNum]-linux-[CPU64]

1.2. Node.js x64 and other 64-bit previous LTS

user@host: $ wget https://nodejs.org/download/release/latest-v[ersionMaj].x/node-v[ersionNum]-linux-[CPU64].tar.xz
user@host: $ tar -xf node-v[ersionNum]-linux-[CPU64].tar.xz
user@host: $ cd node-v[ersionNum]-linux-[CPU64]

1.3. Node.js x86 and other 32-bit Unofficial Builds

user@host: $ wget https://unofficial-builds.nodejs.org/download/release/v[ersionNum]/node-v[ersionNum]-linux-[CPU].tar.xz
user@host: $ tar -xf node-v[ersionNum]-linux-[CPU].tar.xz
user@host: $ cd node-v[ersionNum]-linux-[CPU]

2. Transfer Node.js components to the designated locations.

2.1. Users with sudo privileges.

2.1.1. Remove existing node_modules directory, if any. Modules or dependencies installed globally through "npm install -g" will need to be reinstalled after this.

user@host: $ sudo rm -r /usr/local/lib/node_modules

2.1.2. Copy the Node.js files to the corresponding directories.

user@host: $ sudo cp -R bin/* /usr/local/bin
user@host: $ sudo cp -R include/* /usr/local/include
user@host: $ sudo cp -R lib/* /usr/local/lib
user@host: $ sudo cp -R share/* /usr/local/share

2.2. Users without sudo privileges.

2.2.1. Create corresponding local directories.

user@host: $ mkdir -p ~/.local/bin
user@host: $ mkdir -p ~/.local/include
user@host: $ mkdir -p ~/.local/lib
user@host: $ mkdir -p ~/.local/share

2.2.2. Remove existing node_modules directory, if any. Modules or dependencies installed globally through "npm install -g" will need to be reinstalled after this.

user@host: $ rm -r ~/.local/lib/node_modules

2.2.3. Copy the Node.js files to the corresponding directories.

user@host: $ cp -R lib/* ~/.local/lib
user@host: $ cp -R bin/* ~/.local/bin
user@host: $ cp -R include/* ~/.local/include
user@host: $ cp -R share/* ~/.local/share

2.2.4. Log out, log in again, and check if [ ~/.local/bin ] is included in the environment path.

user@host: $ echo $PATH

3. Verify that Node.js has been installed properly.

user@host: $ node -v
user@host: $ npm -v
user@host: $ npm version

==========

Comments

Popular posts from this blog

Enabling HTTPS in Home Assistant

Configuring the FreeBSD Firewall with IPFW

Running Home Assistant on FreeBSD Servers