gulp-load-plugins.sourcemaps.init() TypeError: 无法读取 undefine
gulp-load-plugins.sourcemaps.init() TypeError: Cannot read property 'init' of undefined
我正在尝试根据我的目的调整 gulp 文件,但我遇到了问题。 我只关心一项任务:
gulp.task('js:browser', function () {
return mergeStream.apply(null,
Object.keys(jsBundles).map(function(key) {
return bundle(jsBundles[key], key);
})
);
});
它正在使用浏览器化将我的捆绑包压缩成一个可用的单个文件。 它使用这两个方法和这个对象:
function createBundle(src) {
//if the source is not an array, make it one
if (!src.push) {
src = [src];
}
var customOpts = {
entries: src,
debug: true
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));
b.transform(babelify.configure({
stage: 1
}));
b.transform(hbsfy);
b.on('log', plugins.util.log);
return b;
}
function bundle(b, outputPath) {
var splitPath = outputPath.split('/');
var outputFile = splitPath[splitPath.length - 1];
var outputDir = splitPath.slice(0, -1).join('/');
console.log(outputFile);
console.log(plugins);
return b.bundle()
// log errors if they happen
.on('error', plugins.util.log.bind(plugins.util, 'Browserify Error'))
.pipe(source(outputFile))
// optional, remove if you don't need to buffer file contents
.pipe(buffer())
// optional, remove if you dont want sourcemaps
.pipe(plugins.sourcemaps.init({loadMaps: true})) // loads map from browserify file
// Add transformation tasks to the pipeline here.
.pipe(plugins.sourcemaps.write('./')) // writes .map file
.pipe(gulp.dest('build/public/' + outputDir));
}
var jsBundles = {
'js/polyfills/promise.js': createBundle('./public/js/polyfills/promise.js'),
'js/polyfills/url.js': createBundle('./public/js/polyfills/url.js'),
'js/settings.js': createBundle('./public/js/settings/index.js'),
'js/main.js': createBundle('./public/js/main/index.js'),
'js/remote-executor.js': createBundle('./public/js/remote-executor/index.js'),
'js/idb-test.js': createBundle('./public/js/idb-test/index.js'),
'sw.js': createBundle(['./public/js/sw/index.js', './public/js/sw/preroll/index.js'])
};
当我运行 gulp 任务 js:bower 时,我收到来自 .pipe(plugins.sourcemaps.init({loadMaps: true}))
表达式的以下错误:
TypeError: Cannot read property 'init' of undefined
我知道这些行是可选的,我可以将它们注释掉,但我确实想要它们。 当我在示例文件中运行代码时,它可以正常工作,当我在我的 gulp 文件中运行它时,它会给我错误。 关于我可能缺少什么的任何建议? 谢谢!
gulp-load-plugins
分析package.json
文件的内容,找出您安装了哪些 Gulp 插件。确保gulp-sourcemaps
属于此处定义的"devDependencies"
。如果未运行
npm install --save-dev gulp-sourcemaps
您的问题很有可能与延迟加载源映射插件有关。如果上述方法没有帮助,请尝试要求这样的gulp-load-plugins
:
var plugins = require('gulp-load-plugins')({lazy:false});
相关文章:
- 从桌面读取python文件时高亮显示代码
- Javascript-如何读取json文件中的列并将其保存在Javascript数组中
- 使用Dnamics CRM 2011中的JavaScript读取子网格的所有记录,而不考虑活动页面
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- TypeError:无法读取属性'推'未定义的JavaScript
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 如何在读取XLS/XLSX本地文件时,使用IE的javascript代码启用未标记为安全的ActiveX控件
- 字符串在将其传递给另一个活动Android JavaScript时读取Null
- NodeJS-readline暂停和恢复事件发射器(逐行读取)
- 未捕获的类型错误:无法读取属性'删除'的未定义
- AngularJS指令出错-无法读取属性'编译'的未定义
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 如何在Javascript中读取unsigned int
- 如何读取表单中的输入数据
- 通过传递图像的URL通过javascript读取/处理图像-类似于PHP中的file_get_contents
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- angularjs无法读取未定义的属性then
- 正在读取JSON,数据未显示
- gulp-load-plugins.sourcemaps.init() TypeError: 无法读取 undefine