DEV Community

Chris Achinga
Chris Achinga

Posted on • Originally published at chrisdevcode.hashnode.dev on

Using JavaScript in JupyterLab

TL;DR This post will take you through installing JupyterLabs and how to add a NodeJS kernel to it in Ubuntu.

Installing JupyterLabs

For a better experience, you should install Jupyter Lab inside a virtual environment.

sudo apt install python3-venv

Enter fullscreen mode Exit fullscreen mode

After the installation is complete, create a new environment:

python3 -m venv jlab

Enter fullscreen mode Exit fullscreen mode

Note that you can replace the jlab with any name of your choice.

Now activate the environment:

. jlab/bin/activate

Enter fullscreen mode Exit fullscreen mode

Activating a virtual environment

Now install Jupyter Lab in Ubuntu:

pip install jupyterlab

Enter fullscreen mode Exit fullscreen mode

Once the installation is complete, you can start Jupyter lab by running:

jupyter lab

Enter fullscreen mode Exit fullscreen mode

Jupyter Labs runs locally on port 8888: http://localhost:8888/

Installing Javascript Kernel

Inside the activated virtual environment, install the javascript kernel by running:

npm install -g ijavascript

Enter fullscreen mode Exit fullscreen mode

To activate the kernel, run:

ijsinstall

Enter fullscreen mode Exit fullscreen mode

Re-start Jupyter lab:

jupyter lab

Enter fullscreen mode Exit fullscreen mode

Javascript in jupyter lab

To test it out, click on the NodeJS logo to start a Javascript lab:

Srunning javascript on jupyter lab

Conclusion

The article demonstrates how to install Jupyter labs in a virtual environment and add a JavaScript kernel.

Resources

https://www.youtube.com/watch?v=gkeh9phGgYo&list=PL1ROSNerT41L9l0-es4HFXyEyEmKwSya4&index=20&t=81s

Top comments (0)