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

Gianluca picture Gianluca · Jan 16, 2018 · Viewed 10.5k times · Source

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.

Answer

Gianluca picture Gianluca · Jan 21, 2018

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.