Coder Social home page Coder Social logo

schmich / connect-browser-sync Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 7.0 28 KB

Connect middleware for BrowserSync

Home Page: https://www.npmjs.org/package/connect-browser-sync

License: MIT License

JavaScript 96.99% HTML 3.01%
browser-sync browsersync connect express javascript middleware server

connect-browser-sync's People

Contributors

capaj avatar edinella avatar kunamatata avatar schmich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

connect-browser-sync's Issues

Error browserSync.events.on

/node_modules/connect-browser-sync/index.js:9
  browserSync.events.on('init', function(config) {
                    ^
TypeError: Cannot read property 'on' of undefined
    at injectBrowserSync (/node_modules/connect-browser-sync/index.js:9:21)
    at Object.<anonymous> (/app.js:32:42)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/bin/www:6:11)
    at Module._compile (module.js:460:26)
[gulp] [nodemon] app crashed - waiting for file changes before starting...

Using:

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
if (app.get('env') == 'development') {
  var browserSync = require('browser-sync');
  var bs = browserSync.init([], {});
  app.use(require('connect-browser-sync')(bs));
}
app.use(express.static(path.join(__dirname, 'public')));



app.use('/', routes);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

Error with BS 1.3.6

connect-browser-sync/index.js:10:25
    snippet = config.api.snippet;
                        ^
TypeError: Cannot read property 'snippet' of undefined

changing "api" to "options" at that line, resolved for me:

    snippet = config.options.snippet;

eventEmitter not directly returned in >= 0.7.0

https://github.com/shakyShane/browser-sync/wiki/Release-history#wiki-070---includes-breaking-changes

the event emitter is now accessible through bs.events.on()

var browserSync = require("browser-sync");
var bs = browserSync.init([], {});
bs.events.on("init", function(data) {
    // works as before
});

Alternatively, in >= 0.7.0, there's a new callback interface.

var browserSync = require("browser-sync");

browserSync.init([], {}, function(err, bs){
    // bs.api.snippet etc etc
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.