你好,我有一个项目,使用gulp和gulpfile.js突然停止工作,尽管没有改变。
我的输出为
cmd.exe /c gulp -tasks-simple系统找不到指定的路径。
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');
});
})我的packages.json包含
"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"
}我继承了这个项目,所以我还没有完全理解它所做的一切,但它已经运行了很多年,然后就失效了。
我最近更新了typescript,并将项目从使用typings文件夹更改为使用@types (我知道typings确实过时了,但这就是项目所在的位置),但项目在更新后仍在工作,并在一段时间后停止工作。我确实确保了所有提到的软件包都已安装,并且所有文件都正确地位于node_modules文件夹中。此外,该项目在visual studio中构建时也没有错误。
编辑:在摆弄它之后,我意识到有趣的是,如果我转到path并从上面的cli运行gulp命令,它们就会成功运行。
Edit2:我对这件事很感兴趣。我的任务运行器浏览器显示了这个输出。
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.发布于 2020-09-22 02:50:44
在花了比我愿意承认的更多的时间来调试它之后,我终于弄清楚了。最终,我不得不将$(PATH)上移到visual studio的外部工具位置下。我是根据这里的答案算出来的。
https://stackoverflow.com/questions/63962686
复制相似问题