Answer the question
In order to leave comments, you need to log in
Error: File not found with singular glob when running JS task in Gulp?
I am compiling a gulp assembly according to a lesson from Youtube. I got stuck on creating a JS task. I wrote the task myself, hung up tracking js files, included it in the assembly.
I tried to google, read the issue on the github through the translator, but I couldn’t figure it out.
gulpfile.js
let project_folder='dist';
let source_folder='src';
let path = {
build: {
html: project_folder + '/',
css: project_folder + '/css/',
js: project_folder + '/js/',
img: project_folder + '/img/',
fonts: project_folder + '/fonts/'
},
src: {
html: [source_folder + '/*.html', '!' + source_folder + '/_*.html'],
css: source_folder + '/scss/style.scss',
js: source_folder + '/js/sctipt.js',
img: source_folder + '/img/**/*.{jpg,png,svg,gif,icon,webp}',
fonts: source_folder + '/fonts/'
},
watch: {
html: source_folder + '/**/*.html',
css: source_folder + '/scss/**/*.scss',
js: source_folder + '/js/**/*.js',
img: source_folder + '/img/**/*.{jpg,png,svg,gif,icon,webp}'
},
clean: './' + project_folder + '/',
}
let {src, dest} = require('gulp'),
gulp = require('gulp'),
browsersync = require('browser-sync').create(),
fileinclude = require('gulp-file-include'),
del = require('del'),
scss = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
group_media = require('gulp-group-css-media-queries'),
clean_css = require('gulp-clean-css'),
rename = require('gulp-rename');
function browserSync(params) {
browsersync.init({
server:{
baseDir: './' + project_folder + '/'
},
port: 3000,
notify: false
})
}
function html() {
return src(path.src.html)
.pipe(fileinclude())
.pipe(dest(path.build.html))
.pipe(browsersync.stream())
}
function js() {
return src(path.src.js)
.pipe(fileinclude())
.pipe(dest(path.build.js))
.pipe(browsersync.stream())
}
function css() {
return src(path.src.css)
.pipe(
scss({
outputStyle: 'expanded'
})
)
.pipe(group_media())
.pipe(
autoprefixer({
overrideBrowserslist: ['last 5 version'],
cascade: true
})
)
.pipe(dest(path.build.css))
.pipe(clean_css())
.pipe(
rename({
extname: '.min.css'
})
)
.pipe(dest(path.build.css))
.pipe(browsersync.stream())
}
function watchFiles(params) {
gulp.watch([path.watch.html], html);
gulp.watch([path.watch.css], css);
gulp.watch([path.watch.js], js);
}
function clean(params) {
return del(path.clean)
}
let build = gulp.series(clean, gulp.parallel(html, js, css));
let watch = gulp.parallel(build, watchFiles, browserSync);
exports.js = js;
exports.css = css;
exports.html = html;
exports.build = build;
exports.watch = watch;
exports.default = watch;
[[email protected] gulp-scss-boilerplate]$ gulp js
[23:44:03] Using gulpfile ~/front/gulp-scss-boilerplate/gulpfile.js
[23:44:03] Starting 'js'...
[23:44:03] 'js' errored after 16 ms
[23:44:03] Error: File not found with singular glob: /home/sh4rov/front/gulp-scss-boilerplate/src/js/sctipt.js (if this was purposeful, use `allowEmpty` option)
at Glob.<anonymous> (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob-stream/readable.js:84:17)
at Object.onceWrapper (events.js:422:26)
at Glob.emit (events.js:315:20)
at Glob.EventEmitter.emit (domain.js:485:12)
at Glob._finish (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:197:8)
at done (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:182:14)
at Glob._processSimple2 (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:688:12)
at /home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:676:10
at Glob._stat2 (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:772:12)
at lstatcb_ (/home/sh4rov/front/gulp-scss-boilerplate/node_modules/glob/glob.js:764:12)
Answer the question
In order to leave comments, you need to log in
Maybe a typo in the file name? sctipt.js
Well, it's not clear why there is one file in the sorts, but you track by the mask.
I have the same error too. Can you help if you have solved this problem?
Got the same error.
The problem was that physically the file moved, and in task'e ( gulpfile.js ) left the old path. Who will google, check the paths to the files. As always, everything from inattention).
Faced such a problem and solved by removing the slash at the beginning of the file path
Exactly the same problem was, the commentator above correctly said everything due to inattention,
in the gulp tasks there was a folder path src/**/*.*
He was looking for the src folder, and due to inattention I forgot to create it, so double-check all the paths and everything should work
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question