Ad
Getting Error When Using Default Task In Gulp, Shows The Following Error In Gitbash : Task Requires A Name That Is String
When I run the command 'gulp' in gitbash this error is displayed for the last line of the code: throw new Error('Task requires a name that is a string');
Error: Task requires a name that is a string
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect'); // Runs a local dev server
var open = require('gulp-open'); // Open a URL in a web browser
var config = {
port: 9005,
devBaseUrl: 'http://localhost',
paths: {
html: './src/*.html',
dist: './dist'
}
};
gulp.task(connect, function(){
connect.server({
root: '[dist]',
port: config.port,
base: config.devBaseUrl,
livereload: true
});
});
gulp.task(open,['connect'], function(){
gulp.src('dist/index.html')
.pipe(open({ url:config.devBaseUrl + ':' + config.port + '/'}));
});
gulp.task(html,function(){
gulp.src(config.paths.html)
.pipe(gulp.src(config.paths.dist))
.pipe(connect.reload());
});
gulp.task('watch', function(){
gulp.watch(config.paths.html, ['html']);
});
gulp.task('default', ['html', 'open', 'watch']);
Ad
Answer
When defining task first argument should be string.
gulp.task('connect', function () {
.....
})
This is corrected file:
var gulp = require('gulp');
var connect = require('gulp-connect'); // Runs a local dev server
var open = require('gulp-open'); // Open a URL in a web browser
var config = {
port: 9005,
devBaseUrl: 'http://localhost',
paths: {
html: './src/*.html',
dist: './dist'
}
};
gulp.task('connect', function(){
connect.server({
root: '[dist]',
port: config.port,
base: config.devBaseUrl,
livereload: true
});
});
gulp.task('open',['connect'], function(){
gulp.src('dist/index.html')
.pipe(open({ url:config.devBaseUrl + ':' + config.port + '/'}));
});
gulp.task('html',function(){
gulp.src(config.paths.html)
.pipe(gulp.src(config.paths.dist))
.pipe(connect.reload());
});
gulp.task('watch', function(){
gulp.watch(config.paths.html, ['html']);
});
gulp.task('default', ['html', 'open', 'watch']);
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad