Search code examples
gulpwindows-server-2012angular-templatecache

gulp-angular-templatecache fails to find the the template file it creates


We are developing a web application using AngularJS and ASP.NET Web API. There is a dev machine set up with GoCD that deploys the app after every commit to dev branch in our github repo. We are using gulp to build the frontend but after the last commit one of the tasks fails to complete.

It's pretty clear that this particular commit has nothing to do with it since it's a trivial 9 lines of css fixes. Against all logic we decided to revert but it didn't help. Gulp completes fine on Windows 10 and Linux but fails on Windows Server 2012. It's not clear why, as it was working perfectly fine for 3 months.

The task that fails:

gulp.task('partials', function () {
  return gulp.src([
    path.join(conf.paths.src, '/app/**/*.html'),
    path.join(conf.paths.tmp, '/serve/app/**/*.html')
  ])
  .pipe($.minifyHtml({
    empty: true,
    spare: true,
    quotes: true
  }))
  .pipe($.angularTemplatecache('templateCacheHtml.js', {
    module: 'portal',
    root: 'app'
  }))
  .pipe(gulp.dest(conf.paths.tmp + '/partials/'));
});

The angularTemplateCache fails with the error message that it cannot find '..src/app/templateCacheHtml.js' but this is the file that it is supposed to create and then move to '/partials/templateCacheHtml.js'.

We've tried to find some clues as to what causes it but there is nothing even remotely connected to that problem. It works perfectly on our local machines.


Solution

  • There is an open issue on GitHub discussing this exact problem: https://github.com/miickel/gulp-angular-templatecache/issues/124

    Apparently gulp-header (a dependency of gulp-angular-templatecache) was updated yesterday that seemed to break the plugin.

    Add the following to your package.json:

    "gulp-header": "1.8.2",

    and run "npm install" should fix the problem.