1

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. 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

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 });
}
Jonathan
  • 1,355
  • 14
  • 22
user10629012
  • 309
  • 1
  • 4
  • 12

1 Answers1

0
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. Test out the web server by loading the finished version of the project.

This server is not included in your download. It is also not included in this gulp script. To serve files easily, you could for example make use of 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://localhost:8080/build/yourfilename.html

etc.

Jonathan
  • 1,355
  • 14
  • 22
  • thank you for the help, what is the function that goes in there? Once I have installed and running this server, how will I be able to view it in my browser as a localhost: – user10629012 Nov 09 '18 at 13:27
  • gulp is not there to serve files, just to concat, minify, uglify, create source maps, etc. The build files can then be served though through any server you choose. – Jonathan Nov 09 '18 at 14:02
  • Okay, I do not understand how to do this to be honest.. which server files could I have in the folder I downloaded? – user10629012 Nov 09 '18 at 14:44
  • can you post an example please? – user10629012 Nov 09 '18 at 14:44
  • I found this code: gulp.task( 'default',['serve']); gulp.task('init', ["nodemon"], function () { browserSync.init({ proxy: 'http://localhost:3000', //APP.js port number - Listens On This Port port: 3128, //Browser Sync Port - Actually Running On 3000 but proxy browser sync runs on 3128 serveStatic: [ './public/'], // Starting Point For Gulpfile - (ESSENTIAL PART, WONT WORK WITHOUT IT) reloadOnRestart: true, // auto-reload all browsers following a Browsersync reload ghostMode:false, open: "external" }); – user10629012 Nov 09 '18 at 15:32