尝试导入rxjs时,'TypeError:dest.end不是函数'

时间:2016-10-16 17:19:00

标签: gulp browserify rxjs

我是Gulp和Browserify的新手,我正在开发一个Typescript项目。一切正常 很好,直到我导入rxjs但从那时起我面临以下错误消息:

d:\Work\rxjsnew\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:523
    dest.end();
         ^
TypeError: dest.end is not a function
    at DestroyableTransform.onend (d:\Work\rxjsnew\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:523:10)
    at DestroyableTransform.g (events.js:260:16)
    at emitNone (events.js:72:20)
    at DestroyableTransform.emit (events.js:166:7)
    at d:\Work\rxjsnew\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:965:16
    at nextTickCallbackWith0Args (node.js:419:9)
    at process._tickCallback (node.js:348:13)

如果删除rxjs导入,则项目编译成功。 这是我的gulpfile:

var gulp = require("gulp");
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var tsify = require("tsify");


gulp.task('scripts', function () {
      return gulp.src('js/*.js')
        .pipe(browserify().on('error', function(e){
            console.log(e);
         }));
  });

gulp.task("default", ["scripts"], function () {
    return browserify({
        basedir: '.',
        debug: true,
        entries: ['src/main.ts'],
        cache: {},
        packageCache: {}
    })
    .plugin(tsify)
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(gulp.dest("dist"))
});

1 个答案:

答案 0 :(得分:0)

安装' @activex / rxjs'以下列方式打包和导入Rx解决了这个问题。

import { Observable } from '@reactivex/rxjs';