سلام وقتتون بخیر من تمام مراحل مثل استاد پیش رفتم و الان از ورژن 20 نود استفاده میکنم.
کد :
const gulp = require("gulp");
const imagein = require("gulp-imagemin");
// Prin MSG
gulp.task("msg", async function () {
return console.log("This is my first task in GULP.JS");
});
// Copy Files
gulp.task("copyFile", function () {
gulp.src("src/*").pipe(gulp.dest("dist"));
gulp.src("src/assets/*").pipe(gulp.dest("dist/assets"));
gulp.src("src/assets/css/*").pipe(gulp.dest("dist/assets/css"));
gulp.src("src/assets/img/*").pipe(gulp.dest("dist/assets/img"));
gulp.src("src/assets/js/*").pipe(gulp.dest("dist/assets/js"));
});
// Minify Images
gulp.task("minifyImg", () => gulp.src("src/assets/img/*").pipe(imagemin()).pipe(gulp.dest("dist/assets/img")));
ارور :
$ gulp minifyImg
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\Amir\OneDrive\Desktop\7learn learning\GULP.JS\node_modules\gulp-imagemin\index.js from C:\Users\Amir\OneDrive\Desktop\7learn learning\GULP.JS\gulpfile.js not supported.
Instead change the require of index.js in C:\Amir\Arsham\OneDrive\Desktop\7learn learning\GULP.JS\gulpfile.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\Amir\OneDrive\Desktop\7learn learning\GULP.JS\gulpfile.js:2:17) {
code: 'ERR_REQUIRE_ESM'
}
وقتی با import سعی کردم package بریزم ارور دیگه ای داد