简体   繁体   English

使用 NPM 安装 Inotify

[英]Installing Inotify with NPM

I'm quite new to nodeJS and I'm trying to install a package called inotify using the Node Package Manager (NPM).我对 nodeJS 很陌生,我正在尝试使用节点包管理器 (NPM) 安装一个名为 inotify 的包。

After installing NPM (on OSX Lion), I tried to install inotify with the command:安装 NPM(在 OSX Lion 上)后,我尝试使用以下命令安装 inotify:

sudo npm install inotify须藤 npm 安装 inotify

And I get the following error:我收到以下错误:

npm http GET https://registry.npmjs.org/inotify
npm http 304 https://registry.npmjs.org/inotify

> inotify@0.2.2 install /usr/local/lib/node_modules/inotify
> node-waf configure build

Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.6.6 
Checking for program node                : /usr/local/bin/node 
Checking for function inotify_init       : not found 
/usr/local/lib/node_modules/inotify/src/wscript:11: error: the configuration failed (see '/usr/local/lib/node_modules/inotify/build/config.log')
npm ERR! error installing inotify@0.2.2

npm ERR! inotify@0.2.2 install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the inotify@0.2.2 install script.
npm ERR! This is most likely a problem with the inotify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls inotify
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "inotify"
npm ERR! cwd /Users/username/code
npm ERR! node -v v0.6.6
npm ERR! npm -v 1.1.4
npm ERR! code ELIFECYCLE
npm ERR! message inotify@0.2.2 install: `node-waf configure build`
npm ERR! message `sh "-c" "node-waf configure build"` failed with 1
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/username/code/npm-debug.log
npm not ok

Can someone help me out with this有人可以帮我解决这个问题吗

The inotify module won't build because it can't find inotify_init . inotify 模块不会构建,因为它找不到inotify_init This is because inotify is not available on OS X.这是因为 inotify 在 OS X 上不可用。

The FSEvents API on OS X provides similar functionality, but it's a completely different API. OS X 上的 FSEvents API 提供了类似的功能,但它是一个完全不同的 API。 The inotify module is not going to work in this situation.在这种情况下 inotify 模块将不起作用。

Depending on what you are trying to do, fs.watch might suit your needs.根据您尝试执行的操作, fs.watch可能适合您的需求。 It abstracts away platform differences:它抽象了平台差异:

  • On Linux systems, this uses inotify .在 Linux 系统上,这使用inotify
  • On BSD systems (including OS X), this uses kqueue .在 BSD 系统(包括 OS X)上,这使用kqueue
  • On SunOS systems (including Solaris and SmartOS), this uses event ports.在 SunOS 系统(包括 Solaris 和 SmartOS)上,这使用事件端口。
  • On Windows systems, this feature depends on ReadDirectoryChangesW .在 Windows 系统上,此功能取决于ReadDirectoryChangesW

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM