Jupyter Notebook

How to Install JupyterHub JavaScript/Node.js Kernel to Run JavaScript/Node.js Codes on Jupyter Notebooks

The programming language support comes as kernels on JupyterHub. The Python kernel comes installed by default on JupyterHub which enables the Python programming language on Jupyter Notebooks. You can use the other programming languages on your Jupyter Notebooks as well. All you have to do is install the appropriate kernels for JupyterHub on your computer.

In this article, we will show you how to install the JupyterHub JavaScript/Node.js kernel on your JupyterHub server so that the JupyterHub users can run and document the JavaScript/Node.js codes on Jupyter Notebooks just as they run and document the Python codes.

NOTE: If you don’t have JupyterHub installed on your computer, you can read one of the articles depending on the Linux distribution that you’re using:

1. How to Install the Latest Version of JupyterHub on Ubuntu 22.04 LTS/ Debian 12/Linux Mint 21

2. How to Install the Latest Version of JupyterHub on Fedora 38+/RHEL 9/Rocky Linux 9

Topic of Contents:

  1. Installing Node.js on Ubuntu/Debian/Linux Mint
  2. Installing Node.js on RHEL/Rocky Linux/Fedora
  3. Checking If Node.js and NPM Are Installed Correctly
  4. Installing the JavaScript/Node.js Kernel on JupyterHub
  5. Checking If the JavaScript/Node.js JupyterHub Kernel Is Installed Correctly
  6. Conclusion
  7. References

Installing Node.js on Ubuntu/Debian/Linux Mint

For the JupyterHub JavaScript/Node.js kernel to work, you must have the Node.js installed on your computer. If you’re using Ubuntu/Debian/Linux Mint or any other Ubuntu/Debian-based Linux distribution as your JupyterHub server, you can install Node.js from the official package repository of your Linux distribution.

First, update the APT package database cache with the following command:

$ sudo apt update

A screenshot of a computer screen Description automatically generated

To install Node.js and Node Package Manager (NPM), run the following command:

$ sudo apt install nodejs npm

To confirm the installation, press “Y” and then press <Enter>.

A screenshot of a computer Description automatically generated

Node.js and NPM are being installed. It takes a while to complete.

A screenshot of a computer Description automatically generated

At this point, Node.js and NPM should be installed.

A screenshot of a computer program Description automatically generated

Installing Node.js on RHEL/Rocky Linux/Fedora

For the JupyterHub JavaScript/Node.js kernel to work, you must have Node.js installed on your computer. If you’re using RHEL/Rocky Linux/Fedora or any other RPM-based Linux distribution as your JupyterHub server, you can install Node.js from the official package repository of your Linux distribution.

First, update the DNF package database cache with the following command:

$ sudo dnf makecache

To install Node.js and Node Package Manager (NPM), run the following command:

$ sudo dnf install nodejs npm

To confirm the installation, press “Y” and then press <Enter>.

A screenshot of a computer Description automatically generated

Node.js and NPM are being installed. It takes a while to complete.

A screenshot of a computer Description automatically generated

At this point, Node.js and NPM should be installed.

Checking If Node.js and NPM Are Installed Correctly

To confirm whether Node.js and NPM are installed correctly, run the following commands:

$ node --version

$ npm --version

As you can see, Node.js 12.22.9 and NPM 8.5.1 are installed on our Ubuntu 22.04 LTS operating system.

A screenshot of a computer Description automatically generated

Installing the JavaScript/Node.js Kernel on JupyterHub

JupyterHub adds the JavaScript/Node.js support through the use of IJavaScript. To install the IJavaScript Node.js package on your computer, run the following command:

$ sudo npm install -g ijavascript

The IJavaScript Node.js package is being installed. It takes a few seconds to complete.

The IJavaScript Node.js package should be installed at this point.

A screenshot of a computer Description automatically generated

Once the IJavaScript Node.js package is installed, you have to install the JupyterHub IJavaScript kernel to enable the JavaScript/Node.js support on JupyterHub notebooks.

First, activate the JupyterHub virtual environment with the following command:

$ . /opt/jupyterhub/bin/activate

To install the JupyterHub IJavaScript kernel system-wide (for all JupyterHub users), run the following command:

$ sudo PATH=$PATH ijsinstall --install=global

A purple and white text Description automatically generated

Checking If the JavaScript/Node.js JupyterHub Kernel Is Installed Correctly

You can check whether the JavaScript/Node.js JupyterHub kernel is installed, run the following command:

$ jupyter-kernelspec list

You should find the JavaScript/Node.js kernel in the available kernels list.

If you log in to JupyterHub, you should find the JavaScript (Node.js) programming language in the “Notebook” section.

To create a JavaScript/Node.js Jupyter notebook, click on JavaScript (Node.js) from the “Notebook” section.

A screenshot of a computer Description automatically generated

A new JupyterHub JavaScript/Node.js notebook should be created.

You can write and document the JavaScript/Node.js codes in the same way as you do in Python codes.

Conclusion

In this article, we showed you how to install Node.js and IJavaScript on Ubuntu/Debian/Linux Mint/RHEL/Rocky Linux/Fedora and other Ubuntu/Debian-based and RPM-based Linux distributions. We also showed you how to install the JavaScript/Node.js kernel on JupyterHub so that you can run and document the JavaScript/Node.js codes on Jupyter notebooks just as you do in Python codes.

References:

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.