paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
10.79k stars 573 forks source link

Error: Cannot find module fsevents #77

Closed j-fliegenschmidt closed 10 years ago

j-fliegenschmidt commented 10 years ago

I just gave chokidar a shot (found you on SO). I got the latest version via NPM (I'm on Win8 64bit), but require() would fail with error "Cannot find module fsevents", after reverting to 0.7.1, that error is gone.
I did try to get fsevents via NPM, but that failed with

npm WARN package.json FSExpose@0.0.0 No repository field. npm http GET https://registry.npmjs.org/fsevents npm http 304 https://registry.npmjs.org/fsevents gypnpm ERR! weird error 1 npm

paulmillr commented 10 years ago

Works for me. Windows 8.1 64bit.

Indeed node-gyp doesn't really build chokidar deps but this is intentional.

$ npm install --save chokidar
$ node
require('chokidar').watch('.')
// watching
j-fliegenschmidt commented 10 years ago

Hmm, that works for me, too. I still get the error in my IDE though- gonna look into it again later.

dweldon commented 10 years ago

I get the same thing on ubuntu 13.04 with node 0.10.22:

  CXX(target) Release/obj.target/fswatch/nodefsevents.o
../nodefsevents.cc:13:39: fatal error: CoreServices/CoreServices.h: No such file or directory
compilation terminated.
make: *** [Release/obj.target/fswatch/nodefsevents.o] Error 1

However, the module works fine.

paulmillr commented 10 years ago

As i've said -- this is expected. Don't worry.

jyoung-fs commented 7 years ago

For people coming here while trying to use nexe on linux to compile a project with this module, you need to comment out this line: https://github.com/paulmillr/chokidar/blob/master/lib/fsevents-handler.js#L7 . Browserify (I believe it's this) tries to gather all dependencies by scanning require's, and it tries to find this dependency which isn't used on linux.

heyimalex commented 7 years ago

It's the same issue if you're using webpack. And probably any other module bundler that needs to statically resolve dependencies. Here's a one liner to fix it.

sed -i '/try { fsevents = require/d' node_modules/chokidar/lib/fsevents-handler.js