Jupyter Notebook

How to Install TypeScript Kernel on JupyterHub to Run TypeScript 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 TypeScript kernel on your JupyterHub server so that the JupyterHub users can run and document the TypeScript 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/CentOS/Fedora
  3. Checking If Node.js and NPM Are Installed Correctly
  4. Installing TypeScript Kernel on JupyterHub
  5. Checking If JupyterHub TypeScript Kernel Is Installed Correctly
  6. Conclusion
  7. References

Installing Node.js on Ubuntu/Debian/Linux Mint

For JupyterHub TypeScript kernel to work, you must have 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/CentOS/Fedora

For JupyterHub TypeScript kernel to work, you must have the Node.js installed on your computer. If you’re using RHEL/Rocky Linux/CentOS/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 TypeScript Kernel on JupyterHub

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

$ sudo npm install -g tslab

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

A screenshot of a computer Description automatically generated

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

Once the tslab Node.js package is installed, you have to install the JupyterHub TypeScript kernel to enable the TypeScript support on JupyterHub notebooks.

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

$ . /opt/jupyterhub/bin/activate

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

$ sudo PATH=$PATH tslab install --prefix=/opt/jupyterhub

A screenshot of a computer Description automatically generated

Checking If JupyterHub TypeScript Kernel Is Installed Correctly

To check whether the tslab TypeScript JupyterHub kernel is installed, run the following command:

$ jupyter-kernelspec list

You should find “tslab” and “jslab” in the available JupyterHub kernels list.

If you log in to JupyterHub, you should find the TypeScript programming language in the “Notebook” section.

To create a TypeScript Jupyter notebook, click on “TypeScript” from the “Notebook” section.

A new JupyterHub TypeScript notebook should be created.

You can write and document the TypeScript codes in the same way as you do in Python codes.

Conclusion

In this article, we showed you how to install Node.js and tslab on Ubuntu/Debian/Linux Mint/RHEL/Rocky Linux/CentOS/Fedora and other Ubuntu/Debian-based and RPM-based Linux distributions. We also showed you how to install the TypeScript kernel on JupyterHub so that you can run and document the TypeScript 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.