schmich / connect-browser-sync Goto Github PK
View Code? Open in Web Editor NEWConnect middleware for BrowserSync
Home Page: https://www.npmjs.org/package/connect-browser-sync
License: MIT License
Connect middleware for BrowserSync
Home Page: https://www.npmjs.org/package/connect-browser-sync
License: MIT License
/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);
});
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;
Is there any way to run both node.js and browser sync at the same time on different ports?
http://blog.nodejs.org/2013/02/07/peer-dependencies/
Since this project is a plugin to browser-sync, we should have a peer dependency on its version.
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
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.