Search code examples
npmplotlyjupyter-labplotly-python

jupyterlab-plotly build npm extensions failed to install on Linux


This is to help those who face a similar issue. My builds were failing when trying to install the jupyterlab-plotly extension. My Jupyter Lab version is Version 1.2.6. The log was as follows:

[LabBuildApp] Building in /home/***/anaconda3/share/jupyter/lab
[LabBuildApp] Yarn configuration loaded.
[LabBuildApp] Node v6.13.1

[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
[LabBuildApp] > node /home/***/anaconda3/lib/python3.7/site-packages/jupyterlab/staging/yarn.js install --non-interactive
[LabBuildApp] yarn install v1.15.2
[1/5] Validating package.json...
[2/5] Resolving packages...
warning jupyterlab-plotly > plotly.js > regl-splom > [email protected]: use String.prototype.padStart()
warning jupyterlab-plotly > plotly.js > point-cluster > bubleify > buble > [email protected]: This is not needed anymore. Use `require('os').homedir()` instead.
[3/5] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=8.3.0". Got "6.13.1"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

[LabBuildApp] npm dependencies failed to install
[LabBuildApp] Traceback (most recent call last):

[LabBuildApp]   File "/home/***/anaconda3/lib/python3.7/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging
    yield

[LabBuildApp]   File "/home/***/anaconda3/lib/python3.7/site-packages/jupyterlab/labapp.py", line 98, in start
    command=command, app_options=app_options)

[LabBuildApp]   File "/home/***/anaconda3/lib/python3.7/site-packages/jupyterlab/commands.py", line 459, in build
    command=command, clean_staging=clean_staging)

[LabBuildApp]   File "/home/***/anaconda3/lib/python3.7/site-packages/jupyterlab/commands.py", line 660, in build
    raise RuntimeError(msg)

[LabBuildApp] RuntimeError: npm dependencies failed to install

[LabBuildApp] Exiting application: JupyterLab
~                                                                                                                                                     
~                                                                                                                                                     
"/tmp/jupyterlab-debug-7x6sz5zm.log" 34L, 1758C

Solution is in answers


Solution

  • The issue, as indicated by the log file, seemed to be that the node in my anaconda environment was outdated.

    $ type node
    node is hashed (/home/***/anaconda3/bin/node)
    
    $ node --version
    v6.13.1
    

    Looking at the nodejs on my machine:

    $ type nodejs
    nodejs is hashed (/usr/bin/nodejs)
    
    $ nodejs --version
    v10.15.2
    

    To get around this issue I did the following:

    1. Navigated to node's parent directory
    2. Made a backup of node just in case
    3. Made a symlink to nodejs here named as "node"
    4. Ran the build
    5. Enabled the jupyterlab-plotly extension
    6. Restarted the Jupyter Lab server

    Commands were as follows:

    cd /home/***/anaconda3/bin/
    cp node node_bak
    rm node
    sudo ln -s /usr/bin/nodejs /home/***/anaconda3/bin/node
    jupyter lab clean
    jupyter lab build
    

    After some time, the build concluded successfully.

    I enabled the jupyterlab-plotly extension from the inbuild extension manager. And I restarted the server.

    My pretty plots started rendering as intended after this. :) Hope this saves you some time.

    Note: replace *** with the paths on your machine