Saturday, 20 May 2017

Sails.js/Condolidate/Twig Error

I'm getting the following error when I request a view in Sails that is using Twig.js:

error: Sending 500 ("Server Error") response:
 TypeError: engine is not a function
    at /usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:479:61
    at /usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:143:5
    at Promise._execute (/usr/lib/node_modules/sails/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/usr/lib/node_modules/sails/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/usr/lib/node_modules/sails/node_modules/bluebird/js/release/promise.js:79:10)
    at promisify (/usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:136:10)
    at Function.exports.twig.render (/usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:473:10)
    at /usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:164:27
    at /usr/lib/node_modules/sails/node_modules/consolidate/lib/consolidate.js:98:5
    at tryToString (fs.js:456:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)

I've tried to fix this many different ways, but I'm still getting the error. I understand Sails should allow me to use anything supported by Consolidate.js, but it just isn't working.

I have:

  • cleared the NPM cache
  • installed Twig.js (v1.10.4) using NPM, and it's in my package.json
    • Removed and reinstalled twig
  • set the engine to 'twig' in config/views.js

This is a fresh Sails project without any other customizations or additions.

I'm a little new to node and sails, any help is appreciated!



via BaconHipster

No comments:

Post a Comment