Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine.configure is not a function v0.14.0 vs v0.14.1 #244

Closed
kimus opened this issue May 29, 2016 · 6 comments
Closed

engine.configure is not a function v0.14.0 vs v0.14.1 #244

kimus opened this issue May 29, 2016 · 6 comments

Comments

@kimus
Copy link

kimus commented May 29, 2016

In v0.14.0 I can do:

var cons = require('consolidate'),
  nunjucks = require('nunjucks');

// add nunjucks to requires so filters can be
// added and the same instance will be used inside the render method
cons.requires.nunjucks = nunjucks.configure();

cons.requires.nunjucks.addFilter('foo', function () {
  return 'bar';
});

With v0.14.1 it will give me the following error:

TypeError: engine.configure is not a function
    at /Users/kimus/test/node_modules/consolidate/lib/consolidate.js:1094:62
    at /Users/kimus/test/node_modules/consolidate/lib/consolidate.js:143:5
    at Promise._execute (/Users/kimus/test/node_modules/consolidate/node_modules/bluebird/js/release/debuggability.js:272:9)
    at Promise._resolveFromExecutor (/Users/kimus/test/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:473:18)
    at new Promise (/Users/kimus/test/node_modules/consolidate/node_modules/bluebird/js/release/promise.js:77:14)
    at promisify (/Users/kimus/test/node_modules/consolidate/lib/consolidate.js:136:10)
    at Function.exports.nunjucks.render (/Users/kimus/test/node_modules/consolidate/lib/consolidate.js:1091:10)
    at /Users/kimus/test/node_modules/consolidate/lib/consolidate.js:164:27
    at /Users/kimus/test/node_modules/consolidate/lib/consolidate.js:98:5
    at /Users/kimus/test/node_modules/loopback/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
@ryanvanderpol
Copy link

+1 I'm also seeing this so I just dropped consolidate and am using nunjucks on its own.

@kimus
Copy link
Author

kimus commented Jun 6, 2016

Workaround it's to change "consolidate": "^0.14.0", to "consolidate": "0.14.0", and wait for a fix

@niftylettuce
Copy link
Collaborator

Hey, see release v0.14.2 which will be published shortly to NPM and GitHub - per #260

@larskarbo
Copy link

I have this excact problem at v0.14.5

@progressor0
Copy link

I had same problem.

I defined cons.requires.nunjucks = nunjucks.configure() and then options.settings.views while calling .render(). Function nunjucks.configure() returns object, so cons.requires.nunjucks is object. And according to the code of ~/node_modules/consolidate/lib/consolidate.js (listed below) consolidate trying to call configure() which is really does not exists.

So I removed options.settings.views and set template folder path in
cons.requires.nunjucks = nunjucks.configure('./templates')

It helped me. Maybe it can help you :)

1118  var engine = options.nunjucksEnv || requires.nunjucks || (requires.nunjucks = require('nunjucks'));
1119
1120  var env = engine;

...

1125      if (options.settings && options.settings.views)
1126        env = engine.configure(options.settings.views);
1127      else if (options.nunjucks && options.nunjucks.configure)
1128        env = engine.configure.apply(engine, options.nunjucks.configure);

@kimus
Copy link
Author

kimus commented Feb 18, 2017

Upgraded today and tested again, and the same problem occurs (using express). Tried some options but none was working (not sure how to send my on configured environment without giving an error of some kind).

So I also just dropped consolidate and using nunjucks on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants