gpt4 book ai didi

javascript - Watchify with gulp 不起作用

转载 作者:行者123 更新时间:2023-11-30 16:49:23 25 4
gpt4 key购买 nike

我已经为监视创建了这个 gulp 任务,但它给出了这个错误:无法读取未定义的属性“缓存”

gulp.task('browserify-With-Watch', function () {
"use strict";
var bundler = browserify({
entries: ['src/js/ede-wrapper.js'], // Only need initial file, browserify finds the deps
debug: true, // Gives us sourcemapping
cache: {},
packageCache: {},
fullPaths: true
});

var watcher = watchify(bundler);

return watcher
.on('update', function () { // When any files update
watcher.bundle() // Create new bundle that uses the cache for high performance
.pipe(source('src/js/ede-wrapper.js'))
// This is where you add uglifying etc.
.pipe(gulp.dest('dist'));
})
.bundle() // Create the initial bundle when starting the task
.pipe(source('src/js/ede-wrapper.js'))
.pipe(gulp.dest('dist'));
});

这是我得到的错误

[17:06:04] Starting 'browserify-With-Watch'...
[17:06:04] 'browserify-With-Watch' errored after 1.6 ms
[17:06:04] TypeError: Cannot read property 'cache' of undefined
at watchify (d:\KHOBI\Source\ede_js_sdk\node_modules\watchify\index.js:13:27)
at Gulp.<anonymous> (d:\KHOBI\Source\ede_js_sdk\gulpfile.js:55:20)
at module.exports (d:\KHOBI\Source\ede_js_sdk\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (d:\KHOBI\Source\ede_js_sdk\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (d:\KHOBI\Source\ede_js_sdk\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (d:\KHOBI\Source\ede_js_sdk\node_modules\gulp\node_modules\orchestrator\index.js:134:8)
at C:\Users\hasithm\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)

希望这不是我使用的 watchify 版本的问题

注意:我已经使用gulp-browserify来browserify

最佳答案

Note: I have used gulp-browserify to browserify

你应该在这里直接使用browserify,而不是gulp-browserify。

watchify 需要一个 browserify 实例,但你给它一个由 gulp-browserify 创建的流。

关于javascript - Watchify with gulp 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30755355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com