I am a newbie, following a tutorial about modern webdev workflow. I get this error message in my console. TypeError: dest.on is not a function
I know, there are related questions and answers here. But I don't understand them. Because I don't know what "dest.on" is related to and what does it do.
This is the code so far:
var gulp = require("gulp");
var sass = require("gulp-sass");
var sourcemaps = require("gulp-sourcemaps");
var autoprefixer = require("auto-prefixer");
var imagemin = require("gulp-imagemin");
var browserSync = require("browser-sync").create();
gulp.task("css", function() {
return gulp
.src("src/sass/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
.pipe(sourcemaps.write("./maps"))
.pipe(gulp.dest("dist/css"));
});
Could anyone explain, what the error message means and how I can solve this particular problem? I am sorry for the redundancy but I found no solution in the existing answers.
Edit:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Maybe it helps adding the package.json
{
"name": "sitepointresponsivewebsite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"auto-prefixer": "^0.4.2",
"browser-sync": "^2.26.3",
"gulp": "^4.0.0",
"gulp-imagemin": "^5.0.3",
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.6.5"
}
}
This is the complete terminal error message
Beratungs-MacBook-Pro-2:sitepointResponsiveWebsite Beratung1$ gulp css
[14:04:02] Using gulpfile ~/Desktop/sitepointResponsiveWebsite/gulpfile.js
[14:04:02] Starting 'css'...
[14:04:02] 'css' errored after 12 ms
[14:04:02] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (/Users/Beratung1/Desktop/sitepointResponsiveWebsite/node_modules/readable-stream/lib/_stream_readable.js:564:8)
at /Users/Beratung1/Desktop/sitepointResponsiveWebsite/gulpfile.js:13:6
at taskWrapper (/Users/Beratung1/Desktop/sitepointResponsiveWebsite/node_modules/undertaker/lib/set-task.js:13:15)
at bound (domain.js:396:14)
at runBound (domain.js:409:12)
at asyncRunner (/Users/Beratung1/Desktop/sitepointResponsiveWebsite/node_modules/async-done/index.js:55:18)
at process._tickCallback (internal/process/next_tick.js:61:11)
With unfamiliar error messages like this, the stack trace is usually the most helpful.
at DestroyableTransform.Readable.pipe (/Users/Beratung1/Desktop/sitepointResponsiveWebsite/node_modules/readable-stream/lib/_stream_readable.js:564:8)
at /Users/Beratung1/Desktop/sitepointResponsiveWebsite/gulpfile.js:13:6
The error is happening in the pipe()
method in readable-stream. dest
is the name of the first argument to pipe()
; the fact that "dest.on" does not exist means that something you passed to pipe()
is not actually a stream.
The second stack frame refers to line 13, which is this pipe()
call:
.pipe(
autoprefixer({
browsers: ["last 2 versions"]
})
)
So, the return value of autoprefixer() is not a stream.
autoprefixer
is:
var autoprefixer = require("auto-prefixer");
Looking at that module on npm: https://www.npmjs.com/package/auto-prefixer. Looks weird, it definitely isn't a stream API though.
The real autoprefixer module is called autoprefixer
, no dash. You can use it together with gulp-postcss as described here: https://www.npmjs.com/package/autoprefixer#gulp
var postcss = require('gulp-postcss')
var autoprefixer = require('autoprefixer')
// .. etc ..
.pipe(postcss([ autoprefixer({
// .. options ..
}) ]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With