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.

watch + merge fails with TypeError: object is not a function

See original GitHub issue

I’m trying to combine watch, and merge

Here is my gulpfile (in coffee sorry), so that you understand what I’m trying to achieve:

gulp plugins

ngClassify = require 'gulp-ng-classify'
sourcemaps = require 'gulp-sourcemaps'
coffee = require 'gulp-coffee'
gutil = require 'gulp-util'
annotate = require 'gulp-ng-annotate'
concat = require 'gulp-concat'
cached = require 'gulp-cached'
remember = require 'gulp-remember'
merge = require 'merge-stream'
debug = require 'gulp-debug'
gutil = require 'gulp-util'
gulp.task 'scripts', ->
    libs = gulp.src(config.files.library.js)
        .pipe cached('libs')
        .pipe sourcemaps.init()
        .pipe concat("libs.js")
       .pipe remember('libs')
    coffee = gulp.src config.files.coffee
        .pipe cached('coffeescripts')
        .pipe sourcemaps.init()
        .pipe ngClassify()
        .pipe coffee().on('error', gutil.log)
        .pipe annotate()
        .pipe remember('coffeescripts')
        .pipe concat("coffee.js")

    return merge(libs, coffee)
        .pipe concat("main.js")
        .pipe sourcemaps.write(".")
        .pipe gulp.dest 'dist'

gulp.task "watch", ->
    gulp.watch(config.files.coffee, ["scripts"])

when a file change, I’m getting following error: [18:37:59] Starting ‘scripts’… [18:37:59] ‘scripts’ errored after 5.35 ms [18:37:59] TypeError: object is not a function at Gulp.<anonymous> (/data/buildbot/granlecoja/main.js:24:122) at module.exports (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:33:7) at Gulp.Orchestrator._runTask (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at Gulp.Orchestrator.start (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/orchestrator/index.js:134:8) at Gulp.<anonymous> (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/index.js:36:18) at Gaze.<anonymous> (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/index.js:18:14) at Gaze.emit (events.js:98:17) at Gaze.emit (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:129:32) at /data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:416:16 at StatWatcher._pollers.(anonymous function) (/data/buildbot/buildbot-nine-demo/buildbot/www/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:327:7) at StatWatcher.emit (events.js:98:17) at StatWatcher._handle.onchange (fs.js:1109:10)

I’m able to narrow the problem to the simpler config:

gulp.task 'scripts2', ->
    coffee = gulp.src config.files.coffee
        .pipe gulp.dest 'dist'
    return merge(coffee)
gulp.task "watch", ->
    gulp.watch(config.files.coffee, ["scripts2"])

which does nothing but copy the file, via a merge-stream, but in this case, script2 task does not even finish.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
yocontracommented, Jul 19, 2014

yeah you can’t declare that twice, that’s your problem

thanks @cognitom for looking through that

0reactions
yocontracommented, Jul 19, 2014

How many files are in src/*/.coffee? Can you run gulp -v as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack-merge merge is not a function - Stack Overflow
In a new version of webpack-merge, It is imported like below. const { merge } = require('webpack-merge');.
Read more >
How to Fix Webpack Merge Is Not a Function - Future Studio
This tutorial shows you how to fix the Webpack merge error not being a function. The Problem: Webpack Merge Is Not a Function....
Read more >
Debugging guide | Google Earth Engine
eeObject.name is not a function error is displayed because the object being added to the map, nonsense , is a string, not an...
Read more >
Schema Merging – GraphQL Tools
This should not be confused with schema stitching, which builds a ... You can use mergeSchemas to merge GraphQLSchema objects together with ...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
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