`jupyterlab` doesn't recognize `nodejs` and `npm` installations

12,751

Solution 1

The issue was with the version of nodejs installed. Ubuntu 16.04 LTS comes with v4.2.6. I've resolved the issue installing nodejs v6. If you need to install it in Ubuntu 16.04 LTS, you can follow this excellent tutorial.

Solution 2

try installing nodejs legacy using

sudo apt install nodejs-legacy

or alternatively you could

sudo ln -s /usr/bin/nodejs /usr/bin/node

the problem is that jupyter expects nodejs to be available using the command node which is not the case anymore

Share:
12,751
Gianluca
Author by

Gianluca

Sr Data Analyst in an ad tech firm. MSc in Economics and Finance. Passionate about Statistics and Machine Learning.

Updated on July 02, 2022

Comments

  • Gianluca
    Gianluca almost 2 years

    I'm having troubles installing the jupyterlab_bokeh extension.

    $ jupyter labextension install jupyterlab_bokeh
    Errored, use --debug for full output:
    ValueError: Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.
    

    I'm using a virtual environment (pyenv plus pyenv-virtualenvwrapper). I've tried to install the two packages first on my local OS (Ubuntu 16.04) and reinstalled jupyterlab but that didn't help. I've also tried to install both nodejs and npm via pip on the virtual enviroment, after having uninstalled the packages on my OS just to make sure they were not conflicting. Unfortunately, neither of the tentative succeeded.

    The weird thing is that if I type the nodejs command on my terminal, I can access a nodejs REPL.

    bokeh==0.12.13
    jupyter-client==5.2.1
    jupyter-core==4.4.0
    jupyterlab==0.31.1
    jupyterlab-launcher==0.10.2
    

    The problem is not limited to the extension jupyterlab_bokeh. I can replicate the same error with the extension jupyterlab-manager.

    I've actually noticed that if I run jupyter labextension list I can see both extensions as correctly installed:

    $ jupyter labextension list
    JupyterLab v0.31.1
    Known labextensions:
       app dir: /home/gianluca/.virtualenvs/rethinking/share/jupyter/lab
    @jupyter-widgets/jupyterlab-manager
            @jupyter-widgets/jupyterlab-manager v0.33.0  enabled  OK
    jupyterlab_bokeh
            jupyterlab_bokeh v0.2.0  enabled  OK
    
    Build recommended, please run `jupyter lab build`:
        @jupyter-widgets/jupyterlab-manager needs to be included in build
        jupyterlab_bokeh needs to be included in build
    

    However, as you can read in the above snipped, a built is recommended. If I try to run the build, this is the error message I see:

    $ jupyter lab build
    [LabBuildApp] > node /home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/staging/yarn.js install
    Traceback (most recent call last):
      File "/home/gianluca/.virtualenvs/rethinking/bin/jupyter-lab", line 11, in <module>
        sys.exit(main())
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
        return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
        app.start()
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/notebook/notebookapp.py", line 1431, in start
        super(NotebookApp, self).start()
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyter_core/application.py", line 255, in start
        self.subapp.start()
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/labapp.py", line 64, in start
        command=command, logger=self.log)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 238, in build
        command=command, clean_staging=clean_staging)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 376, in build
        self._run(['node', YARN_PATH, 'install'], cwd=staging)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/commands.py", line 1158, in _run
        proc = Process(cmd, **kwargs)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/process.py", line 72, in __init__
        self.proc = self._create_process(cwd=cwd, env=env)
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/process.py", line 130, in _create_process
        cmd[0] = which(cmd[0], kwargs.get('env'))
      File "/home/gianluca/.virtualenvs/rethinking/lib/python3.6/site-packages/jupyterlab/jlpmapp.py", line 59, in which
        raise ValueError(msg)
    ValueError: Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.
    

    Again, both nodejs and npm are installed in the operating system.