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

TypeError: Cannot read property 'on' of undefined #74

Closed
resting opened this issue Mar 11, 2016 · 5 comments
Closed

TypeError: Cannot read property 'on' of undefined #74

resting opened this issue Mar 11, 2016 · 5 comments

Comments

@resting
Copy link

resting commented Mar 11, 2016

I'm getting the error below when I include the postcss pipe.
Not sure what's wrong.

TypeError: Cannot read property 'on' of undefined
at DestroyableTransform.Readable.pipe (/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:535:7)
at Gulp.<anonymous> (/gulpfile.js:9:10)
at module.exports (/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
at _combinedTickCallback (node.js:370:9)
at process._tickCallback (node.js:401:11)
at Function.Module.runMain (module.js:449:11)

Heres the Gulpfile.js

var gulp = require('gulp'),
    sass = require('gulp-sass'),
    postcss = require('gulp-postcss'),
    autoprefixer = require('autoprefixer');

gulp.task('css', function () {
    return gulp.src('sass/style.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(postcss[autoprefixer({browsers: ['last 2 versions']})])
        .pipe(gulp.dest(''));
});
@TrySound
Copy link
Member

I already answered you
postcss/postcss#766 (comment)
And you forgot parentheses after postcss word

@w0rm w0rm reopened this Mar 11, 2016
@w0rm
Copy link
Member

w0rm commented Mar 11, 2016

@resting can you set up a test project with a gulp task that I can run to reproduce the issue? The code looks fine to me (except the already mentioned missing parentheses). Also, which version of node do you use?

@resting
Copy link
Author

resting commented Mar 11, 2016

I got .pipe(sass().on('error', sass.logError)) from https://github.com/dlmanning/gulp-sass#basic-usage. Its working on another system too. Listing node and gulp versions below:

Problematic
node: 5.8.0
gulp: 3.9.1

Working
node: 5.4.1
gulp: 3.9.1

@w0rm I don't mind setting up a test project. Do you just need package.json and gulpfile.js?

@resting
Copy link
Author

resting commented Mar 11, 2016

Sorry guys, the solution is at postcss/postcss#766 (comment)
Was missing a parenthesis. Correct syntax below.

.pipe(postcss([
            autoprefixer({browsers: ['last 2 versions']})
        ]))

@w0rm
Copy link
Member

w0rm commented Mar 11, 2016

@resting everyone mentioned the parenthesis, although I assumed it was just a typo :) glad that you figured this out.

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

3 participants