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.

TypeError: listener must be a function

See original GitHub issue

Recently my gulp task to build styles has started to fail with a very cryptic error message and I can’t seem to find any fix. This ran fine before, I can’t really say what has changed since then. I do however always seem to have to reinstall gulp-sass to get it to stop complaining about lib-sass bindings. My task looks like this:

gulp.task('sass', function() {
  gulp.src('./assets/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./dev'));
});

And the error I’m getting:

[14:52:06] TypeError: listener must be a function
    at TypeError (native)
    at Stream.addListener (events.js:142:11)
    at Gulp.<anonymous> (/Applications/MAMP/htdocs/<REDACTED>/<REDACTED>/gulpfile.js:38:18)
    at module.exports (/Applications/MAMP/htdocs/<REDACTED>/<REDACTED>/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Applications/MAMP/htdocs/<REDACTED>/<REDACTED>/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Applications/MAMP/htdocs/<REDACTED>/<REDACTED>/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Applications/MAMP/htdocs/<REDACTED>/<REDACTED>/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /Users/ianaw/.nvm/versions/node/v0.12.7/lib/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14

github_iconTop GitHub Comments

14reactions
gaomeng1900commented, Mar 18, 2016

Just remove “.on(‘error’, sass.logError)” and it will be fine.

5reactions
DutchKevvcommented, Aug 19, 2016

@gaomeng1900 and how would you log the errors then?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: listener must be a function - Stack Overflow
removeListener takes two arguments and the function is supposed to be the second argument, so you are passing the function as the name...
Read more >
TypeError: The listener must be a function index.js:60 - Phaser 3
As the title says, is there anything i can fix?, i really dont wanna touch the framework index files. that feels scary.
Read more >
http.request TypeError: "listener" argument must be a function
After switching to use the request library, I have no issue. Seems to be an underlying issue with the http module.
Read more >
listener must be a function' after editing an error message ...
I get a message: 'events.js:210 throw new TypeError('listener must be a function');' , although it prints out this custom error message ...
Read more >
The "listener" argument must be of type function. Received ...
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined ... console.log ('JorisAndCoStudiosBot is ...
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