简体   繁体   中英

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.

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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