admin管理员组文章数量:1287080
When following the example recipe from the Gulp.js repository. I get an error:
[12:27:31] Using gulpfile C:\GH\riot-tag-build\Gulpfile.js
[12:27:31] Starting 'browserify'...
_stream_readable.js:602
var written = dest.write(chunk);
^
TypeError: Object #<Readable> has no method 'write'
at write (_stream_readable.js:602:24)
at flow (_stream_readable.js:611:7)
at _stream_readable.js:579:7
at process._tickCallback (node.js:442:13)
I have tried to modify the source code to match my requirements and this is the Gulpfile I am trying to run with no luck.
var gulp = require('gulp');
var browserify = require('browserify');
var riotify = require('riotify');
var transform = require('vinyl-transform');
var buffer = require('gulp-buffer');
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var b = browserify({debug: true});
// transform regular node stream to gulp (buffered vinyl) stream
var browserified = transform(function(filename) {
b.add(filename);
return b.bundle();
});
return gulp.src('./main.js')
.pipe(browserified)
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', ['browserify']);
And the whole example can be found from here
Any ideas why the stream might be read-only? Any help appreciated.
When following the example recipe from the Gulp.js repository. I get an error:
[12:27:31] Using gulpfile C:\GH\riot-tag-build\Gulpfile.js
[12:27:31] Starting 'browserify'...
_stream_readable.js:602
var written = dest.write(chunk);
^
TypeError: Object #<Readable> has no method 'write'
at write (_stream_readable.js:602:24)
at flow (_stream_readable.js:611:7)
at _stream_readable.js:579:7
at process._tickCallback (node.js:442:13)
I have tried to modify the source code to match my requirements and this is the Gulpfile I am trying to run with no luck.
var gulp = require('gulp');
var browserify = require('browserify');
var riotify = require('riotify');
var transform = require('vinyl-transform');
var buffer = require('gulp-buffer');
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var b = browserify({debug: true});
// transform regular node stream to gulp (buffered vinyl) stream
var browserified = transform(function(filename) {
b.add(filename);
return b.bundle();
});
return gulp.src('./main.js')
.pipe(browserified)
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', ['browserify']);
And the whole example can be found from here
Any ideas why the stream might be read-only? Any help appreciated.
Share Improve this question asked Apr 3, 2015 at 9:35 Tx3Tx3 6,9164 gold badges39 silver badges52 bronze badges 2- Check the recipe again -- it was updated shortly after you posted this question. @ddprrt's answer looks correct based on the updated recipe – Jake Boone Commented Apr 6, 2015 at 20:14
- I'm not sure I understand the entries: './entry.js', .pipe(source('app.js')) part. In the old version, a source file was specified once: './app.js' But in the new version there's this entry.js introduced. What is that file and why is it involved? – Dtipson Commented Jun 16, 2015 at 15:33
2 Answers
Reset to default 9I get the same problem. And I find the solution. You just downgrade "browserify" version to the latest 9.0.4. And anything will be ok. You can reference the mit history.
https://github./substack/node-browserify/mits/master
====Update====
I solve this error. I use 'through2', the code is as follows.
gulp.src('./src/index.js')
.pipe(through2.obj(function (file, enc, next){
browserify(file.path)
.bundle(function(err, res){
// assumes file.contents is a Buffer
file.contents = res;
next(null, file);
});
}))
.pipe(gulp.dest('./build/'))
The solution is from this issue.
https://github./substack/node-browserify/issues/1044
I'm not sure about vinyl-transform, but I guess the correct way of using browserify is to use it as the start point, and transform the stream afterwards to a vinyl object. At least that's what's in the recipes.
var gulp = require('gulp'),
source = require('vinyl-source-stream'),
browserify = require('browserify');
gulp.task('browserify', function () {
return browserify({
debug: true,
entries: ['./main.js']
}).bundle()
.pipe(source('main.bundle.js'))
.pipe(gulp.dest('./dist/'));
});
本文标签: javascriptObject ltReadablegt has no method 39write39 while using GulpBrowserifyStack Overflow
版权声明:本文标题:javascript - Object #<Readable> has no method 'write' while using Gulp + Browserify - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741306901a2371420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论