0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NunjucksでのエラーコードAssertionError [ERR_ASSERTION]: Task function must be specifiedの対処法

Last updated at Posted at 2020-01-23

個人的な備忘録。

gulpのversionが4の状態で、

$npx gulp nunjucks

上記コマンドを実行すると、
#####AssertionError [ERR_ASSERTION]: Task function must be specified

エラーになる。
version4になった事で仕様が変わった為、
watchの引数の書き方を変える必要があるそうだ。

##gulp.watchの引数の変更

  • ver3のコード
// task:watch
gulp.task('watch', function () {
  gulp.watch(paths.src.template + '**/*.njk', ['nunjucks']);
  gulp.watch(paths.dest.root + '**/*.html', ['reload']);
});

// task:default
gulp.task('default', ['brsync', 'watch']);
  • ver4のコード
// task:watch
gulp.task('watch', function () {
  gulp.watch(paths.src.template + '**/*.njk', gulp.series('nunjucks'));
  gulp.watch(paths.dest.root + '**/*.html', gulp.series('reload'));
});

// task:default
gulp.task('default', gulp.series(gulp.parallel('brsync', 'watch')));
  • 第二引数にgulp.series()を追加し、その中に要素を入れる。

  • 引数が複数ある箇所にはgulp.series()の中にgulp.parallel()を追加し、その中に要素を入れる。

npx gulp nunjucks

その後上記コマンドを実行する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?