question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser sync throws a TypeError on init

See original GitHub issue

BrowserSync throws a TypeError when it attempts to reload:

[12:02:53] TypeError: undefined is not a function
    at Object.init (/Users/conti/dev/foodjournal-web/node_modules/browser-sync/lib/public/init.js:25:25)
    at Gulp.<anonymous> (/Users/conti/dev/foodjournal-web/gulpfile.js:39:15)
    at module.exports (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at Gulp.<anonymous> (/Users/conti/dev/foodjournal-web/node_modules/gulp/index.js:36:18)
    at Gaze.<anonymous> (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/index.js:18:14)
    at Gaze.emit (events.js:110:17)
    at Gaze.emit (/Users/conti/dev/foodjournal-web/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:129:32)

That points to the browser-sync gulp task:

gulp.task('browser-sync', function () {
  browserSync.init({
     server: {
       baseDir: "./public"
     }
   })
})

Any idea what could be going wrong? I’m using version 2.8.2.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
shakyShanecommented, Aug 18, 2015

Make sure you call create() first.

var browserSync = require('browser-sync').create();
var gulp = require('gulp');

gulp.task('browser-sync', function () {
  browserSync.init({
     server: {
       baseDir: "./public"
     }
   })
})
1reaction
devnixcommented, Dec 5, 2016

I’m also affected by this bug, only when I inclide this Javascript, I have no idea where could be the problem: http://imulus.github.io/retinajs/

Read more comments on GitHub >

github_iconTop Results From Across the Web

BrowserSync throws a TypeError on init - Stack Overflow
BrowserSync throws a TypeError when it initalizes: [12:02:53] TypeError: undefined is not a function at Object.init ...
Read more >
[Solved]-BrowserSync throws a TypeError on init-node.js
Coding example for the question BrowserSync throws a TypeError on init-node.js.
Read more >
BrowserSync/browser-sync - Gitter
BrowserSync crashing with a segmentation fault error most of the time we run a gulp-typescript based task which translates our src/**/*.ts into .tmp/**/*.js...
Read more >
BrowserSync keeps reloading infinitely upon JavaScript ...
This happens immediately after changing a JavaScript file and using webpack/browersync ( yarn start command). When running yarn build and testing the website...
Read more >
Getting Started with Gulp.js - Semaphore Tutorial
create(); function browserSync(cb) { sync.init({ server: { baseDir: "./public ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found