0
votes

I am using Kraken.js with Dust as the default view engine. I get this error:

No default engine was specified and no extension was provided. at new View (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/view.js:62:11) at EventEmitter.render (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/application.js:569:12) at ServerResponse.render (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/response.js:961:7) at /home/zhiro/Desktop/kraken/krakil/controllers/index.js:14:13 at Layer.handle [as handle_request] (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/layer.js:95:5) at next (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/layer.js:95:5) at /home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/index.js:277:22 at Function.process_params (/home/zhiro/Desktop/kraken/krakil/node_modules/express/lib/router/index.js:330:12)

I see this error when I call res.render.

'use strict';

var IndexModel = require('../models/index');

module.exports = function (router) {
    var model = new IndexModel();
    router.get('/', function (req, res) {
        res.render('index');
    });
};
1

1 Answers

1
votes

By default, Kraken doesn't configure a default view engine. The view engine tells Express how it should attempt to render files if it doesn't have a renderer explicitly defined for that file extension.

When you configure a new project using yo kraken, one of the questions it asks is what you would like your default view engine to be, but it sounds like you chose None on that step.

To set the default view engine, you simply pass it as part of the config object when instantiating Kraken. You can read about this in the Kraken README, under the heading Configuration-Based Express Settings:

Set the view engine property to the one of the view engines property names (see the section View Engine Configuration) to enable it for template rendering.

{
  "express": {
    [...]
    "view engine": null, // set this to "dust"
    [...]
  }
}