[BUG]: `events` is required but not declared in dependencies

オープン 初心者向け
#8,163 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
83/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, webpack

調査の方向性

まず package.json と、レポートで指定された3つのファイル src/lib/events.js、src/snapshot/toimage.js、src/snapshot/svgtoimg.js を読んでください。提示された厳格な pnpm install と webpack のコマンドで失敗を再現してください。パッケージが必要な events 依存関係を宣言し、厳格なインストールで本番ビルドが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Description

src/lib/events.js, src/snapshot/toimage.js and src/snapshot/svgtoimg.js call require('events'), but events is not in the dependencies of package.json.

Since webpack 5 no longer polyfills Node.js core modules, the bundler resolves events to whatever version the package manager happens to hoist.
Today, it only resolves through a transitive dependency: regl-scatter2d → glslify → glslify-deps → events.
With strict installs (pnpm with hoist=false, Yarn PnP), the build fails.
With hoisted installs, another package's events can be picked up instead (e.g. [email protected]).

This happens with the latest release (4.2.0) and with 2.x.
events is the only Node.js core module still required under src/ (see also #6014 for older ones).

Steps to reproduce

package.json:

{
  "dependencies": { "plotly.js": "4.2.0" },
  "devDependencies": { "webpack": "5.106.0", "webpack-cli": "6.0.1" }
}

src/index.js:

import Plotly from "plotly.js/lib/core";
console.log(Plotly.version);
pnpm install --config.hoist=false
npx webpack --mode production
ERROR in ./node_modules/.pnpm/[email protected]/node_modules/plotly.js/src/lib/events.js 3:19-49
Module not found: Error: Can't resolve 'events' in '.../node_modules/.pnpm/[email protected]/node_modules/plotly.js/src/lib'
主要言語
JavaScript
スター
18.4k
フォーク
2.1k
平均マージ
1日 3時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/plotly.js のほかの issue

plotly/plotly.js の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。