简体   繁体   English

任务“ serve”不在您的gulpfile中

[英]Task 'serve' is not in your gulpfile

I am trying to install trackingJs and I am setting up my environment but I get this error message: Task 'serve' is not in your gulpfile. 我正在尝试安装trackingJs,并且正在设置环境,但出现此错误消息:任务'serve'不在您的gulpfile中。 I am struggling big time setting this up, if anyone has used this before and could advise me in detail how to set up my environment properly. 如果有人以前使用过此工具,并且可能会向我详细建议如何正确设置我的环境,那么我正在努力进行大量设置。 I would really appreciate it. 我真的很感激。

Here is a link to the website: https://trackingjs.com/docs.html 这是网站的链接: https : //trackingjs.com/docs.html

error:

throw err; 抛出错误 ^ ^

Error: Cannot find module '/Users/alex/Downloads/tracking.js-master/server'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Alexs-MacBook-Pro-2:tracking.js-master alex$ node gulpfile.js
Alexs-MacBook-Pro-2:tracking.js-master alex$ gulp serve
[12:59:06] Using gulpfile ~/Downloads/tracking.js-master/gulpfile.js
[12:59:06] Task 'serve' is not in your gulpfile
[12:59:06] Please check the documentation for proper gulpfile formatting
Alexs-MacBook-Pro-2:tracking.js-master alex$ 


'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var header = require('gulp-header');
var jsdoc = require('gulp-jsdoc');
var jshint = require('gulp-jshint');
var nodeunit = require('gulp-nodeunit');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var esformatter = require('gulp-esformatter');
var runSequence = require('run-sequence');

gulp.task('all', ['clean'], function() {
  return runSequence(['build', 'build-data']);
});

gulp.task('clean', function() {
  return gulp.src('build').pipe(rimraf());
});

gulp.task( 'default', [ 'serve' ] );

gulp.task('build', function() {
  var files = [
    'src/tracking.js',
    'src/utils/EventEmitter.js',
    'src/utils/Canvas.js',
    'src/utils/DisjointSet.js',
    'src/utils/Image.js',
    'src/detection/ViolaJones.js',
    'src/features/Brief.js',
    'src/features/Fast.js',
    'src/math/Math.js',
    'src/math/Matrix.js',
    'src/pose/EPnP.js',
    'src/trackers/Tracker.js',
    'src/trackers/TrackerTask.js',
    'src/trackers/ColorTracker.js',
    'src/trackers/ObjectTracker.js',
    'src/trackers/LandmarksTracker.js',
    'src/alignment/Regressor.js',
    'src/alignment/LBF.js'
  ];

  return gulp.src(files)
    .pipe(concat('tracking.js'))
    .pipe(banner())
    .pipe(gulp.dest('build'))
    .pipe(uglify())
    .pipe(rename({
      suffix: '-min'
    }))
    .pipe(banner())
    .pipe(gulp.dest('build'));
});

gulp.task('build-data', function() {
  return gulp.src('src/detection/training/haar/**.js')
    .pipe(banner())
    .pipe(gulp.dest('build/data'))
    .pipe(rename({
      suffix: '-min'
    }))
    .pipe(uglify())
    .pipe(banner())
    .pipe(gulp.dest('build/data'));
});

gulp.task('docs', function() {
  return gulp.src(['src/**/*.js', 'README.md'])
    .pipe(jsdoc('docs'));
});

gulp.task('format', function() {
  return gulp.src(['src/**/*.js', '!src/detection/training/**/*.js'])
    .pipe(esformatter())
    .pipe(gulp.dest('src'));
});

gulp.task('lint', function() {
  return gulp.src('src/**/**.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

gulp.task('test', function(cb) {
  gulp.src('test/*.js')
    .pipe(nodeunit())
    .on('end', cb);
});

gulp.task('test-watch', function() {
  return gulp.watch(['src/**/*.js', 'test/**/*.js'], ['test']);
});

gulp.task('watch', function() {
  gulp.watch('src/**/*.js', ['build']);
  gulp.watch('src/data/*.js', ['build-data']);
});

// Private helpers
// ===============

function banner() {
  var stamp = [
    '/**',
    ' * <%= pkg.name %> - <%= pkg.description %>',
    ' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>',
    ' * @version v<%= pkg.version %>',
    ' * @link <%= pkg.homepage %>',
    ' * @license <%= pkg.license %>',
    ' */',
    ''
  ].join('\n');

  return header(stamp, { pkg: pkg });
}
gulp.task( 'default', [ 'serve' ] );

There you mention that the default task is serve, but no: 您在其中提到默认任务是服务,但没有:

gulp.task('serve', function() { ...

to be found in your code 在您的代码中找到

Edit: the project itself states: 编辑:项目本身指出:

While you're working, you'll need a basic HTTP server to serve your pages. 在工作时,需要一个基本的HTTP服务器来服务您的页面。 Test out the web server by loading the finished version of the project. 通过加载项目的完成版本来测试Web服务器。

This server is not included in your download. 该服务器不包含在您的下载文件中。 It is also not included in this gulp script. 该gulp脚本中也不包含它。 To serve files easily, you could for example make use of http-server: 为了轻松提供文件,您可以例如使用http-server:

Run once: 运行一次:

npm install http-server -g

To start your server: 要启动服务器:

cd /Users/alex/Downloads/tracking.js-master
http-server

or 要么

http-server /Users/alex/Downloads/tracking.js-master

Your project will then be accessible on: 然后,您可以在以下位置访问您的项目:

http://localhost:8080/examples/brief.html HTTP://本地主机:8080 /示例/ brief.html

http://localhost:8080/build/yourfilename.html HTTP://本地主机:8080 /编译/ yourfilename.html

etc. 等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM