Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.3 Undefined is not a function #140

Closed
chyld opened this issue Feb 11, 2015 · 19 comments
Closed

v2.0.3 Undefined is not a function #140

chyld opened this issue Feb 11, 2015 · 19 comments

Comments

@chyld
Copy link

chyld commented Feb 11, 2015

Ran into this error when using v2.0.3.
I'm on Mac OSX 10.10 running Node 0.12 64-bit.

Users/chyld/Code/calculator/node_modules/gulp-less/index.js:68
    }).done(undefined, cb);
       ^
TypeError: undefined is not a function
    at DestroyableTransform._transform (/Users/chyld/Code/calculator/node_modules/gulp-less/index.js:68:8)
    at DestroyableTransform.Transform._read (/Users/chyld/Code/calculator/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/chyld/Code/calculator/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/chyld/Code/calculator/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/chyld/Code/calculator/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/chyld/Code/calculator/node_modules/gulp-less/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at write (/Users/chyld/Code/calculator/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/Users/chyld/Code/calculator/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/Users/chyld/Code/calculator/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at DestroyableTransform.emit (events.js:104:17)

@stephenlacy
Copy link
Contributor

Please add your gulp task

@baldore
Copy link

baldore commented Feb 11, 2015

I'm having the same error. Gulp-less works when I use node 0.10.36, but doesn't run when I set node 0.12 or IO.js 1.1.0. This is my task.

gulp.task('less', function () {
  gulp.src('main.less')
    .pipe(less())
    .on('error', console.error.bind(console))
    .pipe(gulp.dest('css/'));
});

@chyld
Copy link
Author

chyld commented Feb 11, 2015

My gulp task

gulp.task('less', function() {
  gulp.src(paths.lesssrc)
    .pipe(less())
    .on('error', function (err) {
      console.log(err);
    })
    .pipe(gulp.dest(paths.lessdst));
});

@yocontra
Copy link
Member

@ohJeez looks like your PR broke for node 0.12 and io.js - any ideas?

@mattstyles
Copy link

Looks like less.render expects a success and error handler rather than exposing then, done and catch.

The fix is to move the catch handler into param 2 of then and discard the done handler as I think its redundant as the then handler dispatches the "master" callback. This certainly fixes a failing and passing compile using iojs (Ive not idea why this works in 0.10.x). I cant be sure exactly that this is anything more than a sticky-taping over something as I'm not sure the original intention of @ohJeez's PR.

Regarding 0.10.x, no idea why it still works, looks like node is simply ignoring the .catch and .done, logging the return of .then just gives another chainable .then with no catch or done methods to call. I'm going to assume this is a bug with 0.10.x and that 0.12 and 1.x behave as you would expect, but havent done a great deal of digging.

I'm happy to issue a PR, but, like I say, I'm not sure of the original intention of the PR.

@OJezu
Copy link

OJezu commented Feb 11, 2015

Native promise does not have .done, while then/promise has. Less includes then/promise only if no native promises are available.
https://github.com/less/less.js/blob/fb5280f16f124e5062634a22be2f3c99e650d0a4/lib/less/render.js#L12

Quick fix will be replacing .done with .then. Good fix will be always including then/promise in less/less.js . I will open an issue there.

@mattstyles
Copy link

Yeah, I just did some digging and found the same.

You mean replace .done with another .then?

@OJezu
Copy link

OJezu commented Feb 11, 2015

@mattstyles It will work. .done is better, but .then is all we have.

@mattstyles
Copy link

@ohJeez yep, I gotcha, I was just referring to the typo in your earlier comment.

@mattstyles
Copy link

@ohJeez although, you know that final .then wont ever be called and is redundant in es6?

@OJezu
Copy link

OJezu commented Feb 11, 2015

@mattstyles why? It has arguments.

@mattstyles
Copy link

@ohJeez yeah, but the .catch will grab any errors and throw, I'm just going to check but I thought that would end the chain. Thinking about it I guess the error propagates to the final .then.

@OJezu
Copy link

OJezu commented Feb 11, 2015

@mattstyles, not if there is another error thrown inside the .catch() handler. That was one of the reasons of the #118 - there was another error thrown in handler and never caught. That .done() was supposed to be the last resort try to pass something to callback.

@mattstyles
Copy link

@ohJeez oh yeah, I see now, propagates straight down, makes sense I guess. Although that throws up a slightly different issue, it consumes the error so gulp thinks the less compile has been successful. I cant catch the error in the stream, unless I'm missing something?

@mattstyles
Copy link

@ohJeez Ignore my previous comment, plumber will catch the error rather than using .on( 'error' ).

@yocontra
Copy link
Member

Can you try 3.0.0? @Jenius just sent a major PR which switches us from using less directly to using a less wrapper which handles all of this weird shit. the stuff less exports is a pain to deal with

@jumoel
Copy link

jumoel commented Feb 12, 2015

I experienced the same error, and it disappeared on 3.0.0.

@jescalan
Copy link
Contributor

🎉

@JalalAlbasri
Copy link

ty, 3.0.0 working for me too 👍

arve0 added a commit to arve0/codeclub_lesson_builder that referenced this issue Mar 13, 2015
arve0 added a commit to arve0/codeclub_lesson_builder that referenced this issue Mar 13, 2015
GROwen added a commit to GROwen/LeadPagesBuildSystem that referenced this issue Apr 28, 2015
Update the version of gulp-less defined in devDependencies to resolve issue describe here - gulp-community/gulp-less#140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants