简体   繁体   English

在 gulp v4 中运行 gulp-nodemon

[英]Running gulp-nodemon in gulp v4

I've been reading gulp-nodemo n but all the syntax is for a previous version of gulp, I'm trying to run it on V4.我一直在阅读gulp-nodemon,但所有的语法都是针对gulp以前版本的,我正在尝试在 V4 上运行它。

This is what I'm running:这是我正在运行的:

function watcher (genCSS,js) {
  nodemon({
script: './app.js' ,
ext: 'js scss',
ignore: [ 'public/dist/', 'node_modules/' ],
watch:    [tpath.src.js, tpath.src.scss],
tasks: function (changedFiles) {
var tasks = [genCSS,js]
    })
return tasks
} })
}

The error is:错误是:

Task never defined: function done() {
    d.removeListener('error', onError);
    d.exit();
    return tryCatch(cb, arguments);
  }

What is going wrong?出了什么问题?

Solved by reading this issue on github , you have to export the functions, and add them as strings instead.通过在 github 上阅读此问题来解决,您必须导出函数,并将它们添加为字符串。 The code was:代码是:

function watcher (genCSS,js) {
  nodemon({
script: './app.js' ,
ext: 'js scss',
ignore: [ 'public/dist/', 'node_modules/' ],
watch:    [tpath.src.js, tpath.src.scss],
done:done,
tasks: function (changedFiles) {
var tasks = [genCSS,js]
    })
return tasks
}

And now现在

function watcher () {
  nodemon({
script: './app.js' ,
ext: 'js scss',
ignore: [ 'public/dist/', 'node_modules/' ],
watch:    [tpath.src.js, tpath.src.scss],
done:done,
tasks: function (changedFiles) {
var tasks = ['genCSS','js']
    })
return tasks
}

exports.genCSS=genCSS
exports.js=js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM