mcollina / mows

Using MQTT.js in the browser over WebSocket -- Built with browserify!
72 stars 12 forks source link

Browserify steps in readme.md throws JS error. #1

Closed ldstein closed 11 years ago

ldstein commented 11 years ago

I'm currently following the instructions to browserify mows:

npm install -g browserify // install browserify
cd node_modules/mows
npm install . // install dev dependencies
browserify index.js -s mows > mows.js // require mows.js in your client-side app

The generated 'mows.js' file throws the following error once loaded in the browser:

Uncaught Error: Cannot find module './../../node_modules/mows/browser' 

It's possible the browserify input file should be 'browser.js', not 'index.js'.

browserify browser.js -s mows > mows.js // require mows.js in your client-side app

I'm able to use mows successfully browser side using this change.

Simple browser-side app which works with this change:

var client = mows.createClient(3001, 'localhost');

client.subscribe('presence');
client.publish('presence', 'Hello mqtt');

client.on('message', function (topic, message) {
    console.log(message);
});
mcollina commented 11 years ago

Many thanks!