Gulp 4.0.1. Module 'del' not found

I ran into a problem: when building a project in Gulp version 4.0.1, I can't use the 'del' module. The terminal outputs the following: 'ReferenceError: del is not defined'. But I installed the module with the command 'npm i del-D' and in package.json it is.

{
  "name": "testgulp",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "del": "^4.1.1",
    "gulp": "^4.0.1"
  }
}

And accordingly gulpfile:

'use strict';

const gulp = require('gulp');
const clear = require('del');

gulp.task('clear', function() {
    return del.sync(['dist']);
});
Author: letzabelin, 2019-05-05

1 answers

An error means that the del variable is not defined.

'use strict';

const gulp = require('gulp');
const del= require('del');

gulp.task('clear', function() {
    return del.sync(['dist']);
});
 1
Author: Максим Левицкий, 2019-05-05 19:56:01