LoginSignup
5
1

More than 1 year has passed since last update.

`node_modules` を探した話

Last updated at Posted at 2021-08-10

まとめ

  • 思い込みがあると,探すべきところを後回しにしてしまう場合がある.

エラーになった

node_modules/chokidar-cli/node_modules/chokidar/lib/fsevents-handler.js:28
  return (new fsevents(path)).on('fsevent', callback).start();
          ^

TypeError: fsevents is not a constructor
    at createFSEventsInstance (node_modules/chokidar-cli/node_modules/chokidar/lib/fsevents-handler.js:28:11)
    at setFSEventsListener (node_modules/chokidar-cli/node_modules/chokidar/lib/fsevents-handler.js:82:16)
    at FSWatcher.FsEventsHandler._watchWithFsEvents (node_modules/chokidar-cli/node_modules/chokidar/lib/fsevents-handler.js:252:16)
    at FSWatcher.<anonymous> (node_modules/chokidar-cli/node_modules/chokidar/lib/fsevents-handler.js:386:25)
    at LOOP (fs.js:1834:14)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
error Command failed with exit code 1.

よくある解決方法を検索すると?

  • node_modulesを消して,yarn install する
  • npm cache clean --force する

みたいなものがあった.
node_modules/fsevents がおかしな状態になっていて,一度消してみる.というのは理解できるが,cache は関係ないと思っていた.

そもそも無い

プロジェクトルートディレクトリ / サブディレクトリなどの node_modulesfsevents ディレクトリは存在しなかった.
今回の件では,node_modulesディレクトリは関係ないのでは?

無くともよい

fsevents 無くとも動きそう.

fsevents-handler.js#L8-L10
try {
  fsevents = require('fsevents');
} catch (error) {

とはいえ,fsevents があると動かないというのは良くないので,
そちらの対応状況を確認した方がより適切かもしれない.

探した

結局はシンプルに,親ディレクトリに node_modules/fsevents が存在していた.

まとめ

  • 思い込みがある
    • 自分がsrc/* ディレクトリのようなところ配下にソースを置く習慣があるので,それより上に node_modules があると想定していなかった.
      • 親ディレクトリの node_modules についての記憶はないらしかった.

参考

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1