Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: fsevents.watch is not a function #18728

Open
7 tasks done
mutantcornholio opened this issue Nov 21, 2024 · 2 comments
Open
7 tasks done

TypeError: fsevents.watch is not a function #18728

mutantcornholio opened this issue Nov 21, 2024 · 2 comments

Comments

@mutantcornholio
Copy link

Describe the bug

fsevents@~2.3.3 is an optional dependency for vite, and vite can run fine without it.
However, if some other package adds fsevents@1, vite breaks:

file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43399
  const stop = fsevents.watch(path, callback);
                        ^

TypeError: fsevents.watch is not a function
    at createFSEventsInstance (file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43399:25)
    at setFSEventsListener (file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43455:16)
    at FsEventsHandler._watchWithFsEvents (file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43659:18)
    at FsEventsHandler.initWatch (file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43735:23)
    at FsEventsHandler._addToFsEvents (file:///Users/cornholio/dev/tmp/vite-bug/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:43824:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v22.6.0

Reproduction

probably not reproducible on linux, as fsevents is a mac package

Steps to reproduce

npm init
# remixd depends on [email protected], which depends on fsevents@^1.2.7
npm install --save vite @remix-project/remixd

System Info

node v22.6.0
npm 10.9.0
macOS 14.7.1

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Nov 21, 2024

Isn't this more of a bug in the package manager where it's not installing or providing the correct version of fsevents for Vite?

@mutantcornholio
Copy link
Author

mutantcornholio commented Nov 21, 2024

Ideally, yes.
It can be solved on package manager level, and I think yarn's PnP shouldn't be susceptible, for example.
I wouldn't get my hopes up about npm fixing it though anytime soon. It's just the way node_modules work, and I think a lot of code in the industry actually expects it to work like that.

UPD: wait a second... I was under impression that vite's using fsevents directly (as it lists fsevents in its optionalDependencies), but it looks like it uses fsevents via chokidar instead? Probably should be directed to chokidar then..
I even found an (unfortunately closed) issue there paulmillr/chokidar#1180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants