概要
JupyterLabでPlotlyのグラフを表示できるようにした際に、エラーが発生しました。
最終的に解決した方法を残しておきます。
公式サイトを見ながらコマンドを実行していたところ、JupyterLabの拡張機能の部分でエラーになりました。
実行環境
| 環境 | バージョン |
|---|---|
| OS | Windows10 |
| JupyterLab | 3.0.14 |
| Node.js | 15.14.0 |
エラーの内容
コマンドプロンプトで「jupyter labextension install jupyterlab-plotly@4.14.3」を実行した際に下記のようなエラーが発生しました。
エラーメッセージ「npm dependencies failed to install」で調べた方法では解消せず。
> jupyter labextension install jupyterlab-plotly@4.14.3
Building jupyterlab assets (production, minimized)
An error occured.
RuntimeError: npm dependencies failed to install
See the log file for details: C:\Users\User\AppData\Local\Temp\jupyterlab-debug-chqiijw0.log
ログファイルの内容
続いてエラーに記載されているログファイルを確認しました。
yarnのインストールでエラーになっているようです。
Yarn configuration loaded.
Building jupyterlab assets (production, minimized)
> node C:\anaconda3\lib\site-packages\jupyterlab\staging\yarn.js install --non-interactive
yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
warning jupyterlab-chart-editor > react-chart-editor > react-colorscales > rc-slider > babel-runtime > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[3/5] Fetching packages...
error An unexpected error occurred: "C:\\Users\\User\\AppData\\Local\\Yarn\\Cache\\v6\\npm-to-px-1.1.0-b6b269ed5db0cc9aefc15272a4c8bcb2ca1e99ca-integrity\\node_modules\\to-px\\.yarn-metadata.json: Unexpected token h in JSON at position 1999".
info If you think this is a bug, please open a bug report with the information provided in "C:\\anaconda3\\share\\jupyter\\lab\\staging\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
対処方法
コマンドプロンプトで"yarn cache clean" を実行してyarnのキャッシュをクリア後、再度拡張機能のインストールを実行すれば解決しました。
> yarn cache clean
ログファイルのエラーメッセージ中の下記メッセージでWeb検索したところ、参考のページにたどり着きました。
「yarn-metadata.json: Unexpected token h in JSON at position 1999」
参考