简体   繁体   中英

How to access npm package event emitter client side in meteor

I think this is pretty basic but am having trouble finding a solution. I have found an NPM package LOG-WATCHER (example only) that monitors a specific log file on a clients local file system. LOG-WATCHER emits events 'START', 'ACTION', 'END'. Since this file is client only I am using browserify. In my packages.json I have added "LOG-WATCHER": "1.0"

In /client/lib app.browserify.js I have added logWatcher = require("LOG-WATCHER");

logWatcher should now be a global variable that I can use in my app. So my question is how can I access one of the events START/ACTION/END through the logWatcher? Very confused on how to put into place.

npmRequire is a funciton who presume you are on a NodeJs env. So you can use it only on Server.

Using browserify you will be able to create an assert for client. Take a look to this two links : - https://react-in-meteor.readthedocs.org/en/latest/meteor-data/ - https://atmospherejs.com/cosmos/browserify

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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