javascript – Gulp Browserify ReferenceError:未定义source

我得到这个奇怪的错误作为标题.
完整的消息看起来像这样

$gulp browserify [01:21:03] Using gulpfile F:\CSC
Assignments\FinalProject\HotelProject\gulpfile.js [01:21:03] Starting
‘browserify’… [01:21:03] ‘browserify’ errored after 15 ms [01:21:03]
ReferenceError: source is not defined
at Gulp. (F:\CSC Assignments\FinalProject\HotelProject\gulpfile.js:109:15)
at module.exports (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (F:\CSC Assignments\FinalProject\HotelProject\node_modules\gulp\node_modules\orchestrator\index.js:134:8)
at C:\Users\LUCKYLAM\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3

我是新手,在花了几个小时搞清楚造成问题的原因后,我不知道这里有什么问题.请帮忙.

这是我的/app/js/script.js

require('angular');

var app = angular.module('app', []);

gulpfile.js:

gulp.task('browserify', function() {
    return browserify('./app/js/script.js')
        .bundle()
        .pipe(source('main.js'))

        // saves it the public/js/ directory
        .pipe(gulp.dest('./dist/js/kk/'));
});

我的文件夹结构javascript  –  Gulp Browserify ReferenceError:未定义source

解决方法:

我猜你错过了一个npm package:vinyl-source-stream.

尝试使用npm install vinyl-source-stream –save-dev和你的gulpfile.js中安装它,如下所示:

var source = require('vinyl-source-stream');
上一篇:javascript – 错误:缺少正面水珠


下一篇:windows 找不到文件gpedit.msc