jupyterlab-plotly build npm 扩展安装失败 Linux

jupyterlab-plotly build npm extensions failed to install on Linux

这是为了帮助那些面临类似问题的人。尝试安装 jupyterlab-plotly 扩展时,我的构建失败了。我的 Jupyter Lab 版本是 1.2.6 版。日志如下:

[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 > left-pad@1.3.0: use String.prototype.padStart()
warning jupyterlab-plotly > plotly.js > point-cluster > bubleify > buble > os-homedir@2.0.0: This is not needed anymore. Use `require('os').homedir()` instead.
[3/5] Fetching packages...
error ws@7.2.1: 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

答案在答案中

如日志文件所示,问题似乎是我的 anaconda 环境中的 node 已过时。

$ type node
node is hashed (/home/***/anaconda3/bin/node)

$ node --version
v6.13.1

查看我机器上的 nodejs:

$ type nodejs
nodejs is hashed (/usr/bin/nodejs)

$ nodejs --version
v10.15.2

为了解决这个问题,我做了以下事情:

  1. 导航到 node 的父目录
  2. 备份 node 以防万一
  3. 创建了指向 nodejs 的符号链接,此处命名为 "node"
  4. 运行 构建
  5. 启用 jupyterlab-plotly 扩展程序
  6. 重新启动了 Jupyter Lab 服务器

命令如下:

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

一段时间后,构建成功结束。

我从内置扩展管理器中启用了 jupyterlab-plotly 扩展。然后我重新启动了服务器。

在此之后,我的漂亮情节开始按预期呈现。 :) 希望这能为您节省一些时间。

注意:将 *** 替换为您计算机上的路径