Hello I have a project that uses gulp and the gulpfile.js suddenly has stop working despite not being changed.
my output reads
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 enviroment 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');
});
})
and my packages.json contains
"devDependencies": {
"del": "^2.0.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-debug": "^2.1.2",
"gulp-less": "^3.0.3",
"gulp-rename": "^1.2.2",
"gulp-sloc": "^1.0.4",
"gulp-sourcemaps": "^1.5.2",
"gulp-tslint": "^3.6.0",
"gulp-typedoc": "^1.2.1",
"gulp-typescript": "^2.14.1",
"gulp-uglify": "^1.4.0",
"typescript": "^4.0.2"
},
"dependencies": {
"@types/angular-route": "^1.7.1",
"@types/angular-ui-bootstrap": "^0.13.46",
"@types/jquery": "^3.5.1",
"@uirouter/angularjs": "^1.0.28",
"angular": "^1.4.5",
"angular-google-chart": "^0.1.0",
"angular-route": "^1.4.5",
"angular-ui-bootstrap": "^2.5.6",
"bootstrap": "^3.3.5",
"d3": "^3.5.16",
"floatthead": "^1.4.5",
"jquery": "^2.2.4",
"n3-charts": "^2.0.14"
}
I inherited this project so I don't yet fully understand everything that this is doing, but it has been functioning for years and just gave out.
I did both recently update typescript and changed the project from using a typings folder to using @types (I know typings is really outdated, but that is where the project was) but the project was working since the update and stopped working some time later. I did ensure that all the mentioned packages are installed and all the files are correctly in the node_modules folder. Also the project builds in visual studio error free.
Edit: after messing around with it I realized that interestingly if I go to the path and run the gulp commands from above from the cli they successfully run.
Edit2: Im pulling my hair out over this one. My task runner explorer shows 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.
After spending more time than I care to admit debugging this I finally figured it out. It ended up being that I had to move my $(PATH) up under visual studio locations of external tools. I figured it out based on this answer over here