gulp and assemble not working - throws "TypeError: expected helpers to be an object"

249 Views Asked by At

Hi it's a while since I used my gulp stack with assemble.io and... I found it does not work;

Using Node v.15.11.0 and:

    "assemble": "^0.24.3",
    "gulp": "^4.0.2",
    "handlebars": "^4.7.7",
    "handlebars-helpers": "^0.10.0

My gulp task:

const   gulp = require('gulp'),          
    extname = require('gulp-extname'),
    assemble = require('assemble')(),  
    helpers = require('handlebars-helpers')(),
    CONFIG = require('../config.js');

gulp.task('assemble', function() {
    assemble.option('layoutDelims', /{{>[ \t]*?(body)[ \t]*?}}/g);
    assemble.option('layout', 'index');
    assemble.option('assets','/Assets');
    assemble.partials('./source/Templates/includes/partials/**/*.html');
    assemble.layouts('./source/Templates/layouts/*.html');
    assemble.pages('./source/Templates/pages/**/*.html');
    assemble.data('./source/Templates/data/**/*.json');
    assemble.helpers('./source/Templates/helpers/**/*.js')

    return assemble.toStream('pages')
      .pipe(assemble.renderFile())
      .pipe(extname())
      .pipe(assemble.dest(CONFIG.PATHS.destinationdir+'/'));
   });

it throws this exception:

TypeError: expected helpers to be an object
at AsyncHelpers.wrapHelpers (/Users/riccardo/Progetti/my-foundation-1/node_modules/async-helpers/index.js:162:11)
at AsyncHelpers.wrapHelper (/Users/riccardo/Progetti/my-foundation-1/node_modules/async-helpers/index.js:142:21)
at AsyncHelpers.wrapHelpers (/Users/riccardo/Progetti/my-foundation-1/node_modules/async-helpers/index.js:177:25)
...

(will provide the full message if you need)

I am not using "weird" helpers, just the plain partial inclusion {{>somepartial}}

Thank you for your help

[edit]

on another project on the same PC using "handlebars": "^4.7.6" everything works; I tried to downgrade to "handlebars": "^4.7.6" but no luck so far (maybe a cache somewhere?)

2

There are 2 best solutions below

0
kierzniak On

Probably Assemble project is not maintained anymore. Last version 0.24.3 was released in 20 May 2017 and it is not compatible with newer version of Node.js. I need to downgrade Node.js using NVM to 6 version to omit this error.

0
recyclebin5385 On

I encountered a similar problem and managed to find a solution.

There seems to be a bug in later versions of async-helpers which Assemble indirectly depends on. Try downgrading async-helpers to an earlier version. I did not test all versions, but at least 0.3.9 seems OK.

Below is an npm command to downgrade.

npm install -D [email protected]