Install Node.js 22|20 LTS and npm on openSUSE 15

Node.js is an open-source, cross-stage, back-end JavaScript runtime climate that sudden spikes in demand for the V8 motor and executes JavaScript code outside an internet browser. Node.js allows designers to utilize JavaScript to compose order line instruments and for server-side scripting running scripts server-side to create dynamic site page content before the page is shipped off the client’s internet browser. Thus, Node.js addresses a “JavaScript all over” paradigm,[6] binding together web-application improvement around a solitary programming language, rather than various dialects for server-side and customer-side scripts.

npm is a package manager for the JavaScript programming language kept up with by npm, Inc. npm is the default package manager for the JavaScript runtime climate Node.js. It comprises of an order line customer, likewise called npm, and a web-based data set of public and paid-for private bundles called the npm registry.

Features of Node.js

  • Offbeat and Event-Driven All APIs of the Node.js library are nonconcurrent, that is, non-obstructing. It basically implies a Node.js-based server never trusts that an API will bring information back. The server moves to the following API in the wake of calling it and a notice component of Events of Node.js assists the server with getting a reaction from the past API call. 
  • Extremely Fast. Being based on Google Chrome’s V8 JavaScript Engine, the Node.js library is exceptionally quick in code execution. 
  • Single-Threaded however Highly Scalable Node.js utilizes a solitary strung model with occasion circling. The occasion system assists the server with reacting in a non-impeding manner and makes the server exceptionally versatile instead of customary servers which make restricted strings to deal with demands. Node.js utilizes a solitary strung program and a similar program can offer support to a lot bigger number of solicitations than customary servers like Apache HTTP Server. 
  • No Buffering Node.js applications never cradle any information. These applications just yield the information in lumps. 

Install Node.js 22|20 LTS and npm in openSUSE 15 With NVM

NVM stands for Node Version Manager. Is a tool used to monitor and track versions of Node.js as they are released in their remote repositories. This gives you the freedom to choose which version you want to install at that particular time.

Step 1: Install NVM on openSUSE 15

Create a ~/.bashrc, ~/.profile or ~/.zshrc file where source strings will be appended. This enables nvm to be reactivated on every reboot.

touch ~/.bashrc

To install nvm, execute the command below in your terminal. The command downloads a bash script from GitHub then installs it automatically. Visit github.com to check the latest version then replace it in the script below. at this time latest version was v0.39.0.

### Using latest in master branch with curl ###
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

### Using latest in master branch with wget ###
sudo wget -qO-  https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh| bash

The message below will be displayed.

=> Downloading nvm as script to '/root/.nvm'

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Refresh the bash profile.

source ~/.bashrc

Now check to confirm installed versions of nvm and npm.

$ nvm -v
0.40.1

Step 2: Install Node.js 22|20 LTS and npm using nvm

With help of NVM, you can install multiple versions of Node.js and able to switch to the version you want to use anytime. Use the ls-remote command to check available versions of Node.js. By default, the installation of Node.js will install npm as well.

$ nvm ls-remote

...   v16.20.2   (Latest LTS: Gallium)
        v17.0.0
        v17.0.1
        v17.1.0
        v17.2.0
        v17.3.0
        v17.3.1
        v17.4.0
        v17.5.0
        v17.6.0
        v17.7.0
        v17.7.1
        v17.7.2
        v17.8.0
        v17.9.0
        v17.9.1
        v18.0.0
        v18.1.0
        v18.2.0
        v18.3.0
        v18.4.0
        v18.5.0
        v18.6.0
        v18.7.0
        v18.8.0
        v18.9.0
        v18.9.1
       v18.10.0
       v18.11.0
       v18.12.0   (LTS: Hydrogen)
       v18.12.1   (LTS: Hydrogen)
       v18.13.0   (LTS: Hydrogen)
       v18.14.0   (LTS: Hydrogen)
       v18.14.1   (LTS: Hydrogen)
       v18.14.2   (LTS: Hydrogen)
       v18.15.0   (LTS: Hydrogen)
       v18.16.0   (LTS: Hydrogen)
       v18.16.1   (LTS: Hydrogen)
       v18.17.0   (LTS: Hydrogen)
       v18.17.1   (LTS: Hydrogen)
       v18.18.0   (LTS: Hydrogen)
       v18.18.1   (LTS: Hydrogen)
       v18.18.2   (LTS: Hydrogen)
       v18.19.0   (LTS: Hydrogen)
       v18.19.1   (LTS: Hydrogen)
       v18.20.0   (LTS: Hydrogen)
       v18.20.1   (LTS: Hydrogen)
       v18.20.2   (LTS: Hydrogen)
       v18.20.3   (LTS: Hydrogen)
       v18.20.4   (LTS: Hydrogen)
       v18.20.5   (LTS: Hydrogen)
       v18.20.6   (Latest LTS: Hydrogen)
        v19.0.0
        v19.0.1
        v19.1.0
        v19.2.0
        v19.3.0
        v19.4.0
        v19.5.0
        v19.6.0
        v19.6.1
        v19.7.0
        v19.8.0
        v19.8.1
        v19.9.0
        v20.0.0
        v20.1.0
        v20.2.0
        v20.3.0
        v20.3.1
        v20.4.0
        v20.5.0
        v20.5.1
        v20.6.0
        v20.6.1
        v20.7.0
        v20.8.0
        v20.8.1
        v20.9.0   (LTS: Iron)
       v20.10.0   (LTS: Iron)
       v20.11.0   (LTS: Iron)
       v20.11.1   (LTS: Iron)
       v20.12.0   (LTS: Iron)
       v20.12.1   (LTS: Iron)
       v20.12.2   (LTS: Iron)
       v20.13.0   (LTS: Iron)
       v20.13.1   (LTS: Iron)
       v20.14.0   (LTS: Iron)
       v20.15.0   (LTS: Iron)
       v20.15.1   (LTS: Iron)
       v20.16.0   (LTS: Iron)
       v20.17.0   (LTS: Iron)
       v20.18.0   (LTS: Iron)
       v20.18.1   (LTS: Iron)
       v20.18.2   (LTS: Iron)
       v20.18.3   (Latest LTS: Iron)
        v21.0.0
        v21.1.0
        v21.2.0
        v21.3.0
        v21.4.0
        v21.5.0
        v21.6.0
        v21.6.1
        v21.6.2
        v21.7.0
        v21.7.1
        v21.7.2
        v21.7.3
        v22.0.0
        v22.1.0
        v22.2.0
        v22.3.0
        v22.4.0
        v22.4.1
        v22.5.0
        v22.5.1
        v22.6.0
        v22.7.0
        v22.8.0
        v22.9.0
       v22.10.0
       v22.11.0   (LTS: Jod)
       v22.12.0   (LTS: Jod)
       v22.13.0   (LTS: Jod)
       v22.13.1   (Latest LTS: Jod)
        v23.0.0
        v23.1.0
        v23.2.0
        v23.3.0
        v23.4.0
        v23.5.0
        v23.6.0
        v23.6.1
        v23.7.0

From above, you can choose the version you would like to download. To download version 22 LTS, run:

$ nvm install 22
Downloading and installing node v22.13.1...
Downloading https://nodejs.org/dist/v22.13.1/node-v22.13.1-linux-x64.tar.xz...
############################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.13.1 (npm v10.9.2)
Creating default alias: default -> 22 (-> v22.13.1)

To install version 20 of Node.js, use the command below:

$ nvm install 20 
Downloading and installing node v20.18.3...
Downloading https://nodejs.org/dist/v20.18.3/node-v20.18.3-linux-x64.tar.xz...
############################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v20.18.3 (v10.8.2)

To switch from one version of Node.js to another use nvm use $VERSION command. The below illustration shows how to change from v14 to v16 and vice versa.

### Using Node.js 22 ###
$ nvm  use  v22.13.1
Now using node v14.18.2 (npm v10.8.2)
$ node -v
v22.13.1

### Using Node.js 20 ###
$ nvm  use  v20.18.3
Now using node v20.18.3 (npm v10.8.2)
$ node -v
v20.18.3

Step 3: Create Hello World Application with Node.js

To start with, you need to create a package.json file that holds your application properties like the name of the application and so on. We are going to use Node Package Manager to help us create the file as shown below.

$ mkdir hello-world
$ cd hello-world
$ npm init 
#Command output#
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.


Press ^C at any time to quit.
package name: (hello-world) 
version: (1.0.0) 
description: My First Nodejs Application
entry point: (index.js) server.js
test command: 
git repository: 
keywords: hello-world
author: Cloudspinx Support
license: (ISC) GPL-3.0
About to write to /home/cloudspinx/hello-world/package.json:

Confirm below if the information if all is the accept to write the configurations.


{
  "name": "hello-world",
  "version": "1.0.0",
  "description": "My First Nodejs Application",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "hello-world"
  ],
  "author": "Cloudspinx Support",
  "license": "GPL-3.0"
}


Is this OK? (yes) y

Create the entry point file you chose up there in your webroot folder. In my case, am going to create a server.js file in /var/www/html. Add lines of code below in the file, save then exit the editor.

$ vim server.js
const http = require('http');

const server = http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, World!\n Welcome To Node.js on openSUSE Leap 15.6 !');
});

const PORT = 3000;
server.listen(PORT, () => {
    console.log(`Server running at http://localhost:${PORT}/`);
});

Start the server with the node command.

$ node server.js 
Server started on http://localhost:3000/; press Ctrl-C to terminate...!

Open URL or your server IP in the browser to view the page http://localhost:3000

Wrapping Up

In this brief guide, we have learned how you can install Node.js and npm on OpenSUSE 15. With help of NVM, makes it simple and easier to check and download the desired version of Node which comes with npm as a default package. Node helps you run and compile JavaScript outside the browser, unlike native JS frameworks which compile in browsers like Chrome. Thank you for your support and don’t forget to check out our previous releases below:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

One of the most effective control panels for web hosting that is used to host websites and administer web servers […]

Beekeeper Studio is an open-source completely free cross-platform SQL editor and database manager. It is available for Mac, Linux, and […]

OpenResty® is a full-featured web platform that uses our improved Nginx core to scale online applications and services. Its purpose […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.