Using svrx from API: fsevents.watch is not a function
Closed this issue · 2 comments
imyzf commented
xuchaoying commented
Cannot reproduce now, feel free to reopen the issue if there's still a problem
xuchaoying commented
This bug is macOS only.
fsevents.watch
is a new func in fsevents@2
. And svrx
depends on chokidar@3
, and fsevents@2
is an optional dependency of chokidar@3
.
Unfortunately, svrx
uses shrinkwrap to lock all dependencies, which will drop all optional dependencies. That means svrx
won't install fsevents
at all.
chokidar
will check if fsevents
exist before use, which will prevent 'not found fsevents error':
let fsevents;
try {
fsevents = require('fsevents');
} catch (error) {
if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
}
However, if your project has fsevents
as a dependency and is not a version of 2, errors like 'fsevents.watch is not a function' might occur.
The workaround is add fsevents@2
as a dependency in your own project.