Hey there, I've encountered an issue with my project that uses gulp. The gulpfile.js suddenly stopped working without any changes made to it.
The output I'm getting is:
cmd.exe /c gulp --tasks-simple The system cannot find the path specified.
gulpfile.js
/// <binding ProjectOpened='watchTS' />
var gulp = require('gulp');
var less = require('gulp-less'),
path = require('path'),
rename = require('gulp-rename'),
del = require('del'),
ts = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
tslint = require('gulp-tslint'),
sloc = require('gulp-sloc'),
debug = require('gulp-debug'),
typedoc = require('gulp-typedoc');
var lib = './lib/';
var tsProject = ts.createProject('tsconfig.json');
gulp.task('init',function(){
del.sync('./lib/');
gulp.src([
'./node_modules/jquery/dist/jquery.min.js',
'./node_modules/d3/d3.min.js',
'./node_modules/angular/angular.min.js',
'./node_modules/n3-charts/build/LineChart.min.js',
'./node_modules/angular-route/angular-route.min.js',
'./node_modules/floatthead/dist/jquery.floatThead.min.js',
'./node_modules/angular-google-chart/ng-google-chart.min.js',
'./node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js'
])
.pipe(concat('lib.js'))
.pipe(gulp.dest('lib'));
gulp.src([
'./node_modules/bootstrap/dist/css/bootstrap.css',
'./node_modules/n3-charts/build/LineChart.min.css'
])
.pipe(gulp.dest('lib'))
});
gulp.task('slocTS', function () {
return gulp.src(['FrontEnd/**/*.ts'])
//.pipe(debug())
.pipe(sloc({ tolerant: true }))
})
gulp.task('slocJS', function () {
return gulp.src(['Scripts/**/*.js'])
//.pipe(debug())
.pipe(sloc())
})
/** Builds out documentation for our environment on the typescript side*/
gulp.task('buildDocs', function () {
return gulp.src(['FrontEnd/**/*.ts'])
.pipe(typedoc({
target: 'es5',
out: 'FrontEnd/docs/',
mode: 'file'
}));
})
gulp.task('buildTSLogin', function () {
return gulp.src(['FrontEnd/**/*.ts', '!FrontEnd/ApplicationStartup.ts'])
.pipe(tslint())
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(concat('loginApp.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('lib'));
});
gulp.task('buildTS', function () {
return gulp.src(['FrontEnd/ApplicationStartup.ts', 'FrontEnd/**/*.ts'])
.pipe(tslint())
.pipe(tslint.report('verbose', {
emitError: false
}))
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(concat('app.js'))
/*.pipe(uglify({
mangle:true
}))*/
.pipe(sourcemaps.write())
.pipe(gulp.dest('lib'));
});
gulp.task('buildProductionTSLogin', function () {
return gulp.src(['FrontEnd/**/*.ts', '!FrontEnd/ApplicationStartup.ts'])
.pipe(ts(tsProject))
.pipe(concat('loginApp.js'))
.pipe(uglify({
mangle: true
}))
.pipe(gulp.dest('lib'));
});
gulp.task('buildProductionTS', function () {
return gulp.src(['FrontEnd/ApplicationStartup.ts', 'FrontEnd/**/*.ts'])
/*.pipe(tslint())
.pipe(tslint.report('verbose', {
emitError: false
}))
.pipe(sourcemaps.init())*/
.pipe(ts(tsProject))
.pipe(concat('app.js'))
.pipe(uglify({
mangle: true
}))
/*.pipe(sourcemaps.write())*/
.pipe(gulp.dest('lib'));
});
gulp.task('buildProduction', ['init', 'buildProductionTSLogin'], function () {
gulp.start('buildProductionTS');
})
gulp.task('watchTS', function () {
gulp.watch('FrontEnd/**/*.ts', function (event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulp.start('buildTS');
//gulp.start('buildTSLogin');
});
})
Additionally, my packages.json includes:
"devDependencies": {
"del": "^2.0.1",
...
This project was handed down to me so I'm still learning about its functionalities. It has been running smoothly for years until now.
Recently, I updated TypeScript and migrated from a typings folder to using @types. Although the project worked fine after the update, it suddenly stopped functioning. All required packages are installed correctly in the node_modules folder, and the project builds error-free in Visual Studio.
Edit: After some troubleshooting, I discovered that if I run the gulp commands mentioned above directly from the command line at the specified path, they work successfully.
Edit2: I'm quite frustrated as my task runner explorer keeps showing this output:
cmd.exe /c gulp --tasks-simple
The system cannot find the path specified.
cmd.exe /c gulp --tasks-simple
The system cannot find the path specified.
cmd.exe /c gulp --tasks-simple
The system cannot find the path specified.