question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't find ViewEngine "nunjucks"

See original GitHub issue
2017-03-06 21:48:50,902 INFO 86405 [master] egg started on http://127.0.0.1:7001 (1243ms)
2017-03-06 21:48:55,588 ERROR 86418 [-/::1/-/8ms GET /] nodejs.AssertionError: Can't find ViewEngine "nunjucks"
    at ContextView.[contextView#getViewEngine] (/Users/guomiaoyou/github/dumplings/node_modules/egg-view/lib/context_view.js:91:5)
    at ContextView.[contextView#render] (/Users/guomiaoyou/github/dumplings/node_modules/egg-view/lib/context_view.js:72:39)
    at next (native)
    at onFulfilled (/Users/guomiaoyou/github/dumplings/node_modules/co/index.js:65:19)
name: 'AssertionError'
actual: undefined
expected: true
operator: '=='
message: 'Can\'t find ViewEngine "nunjucks"'
generatedMessage: false
pid: 86418
hostname: guomiaoyoudeMacBook-Pro.local

config/config.default.js 配置如下

'use strict';
const path = require('path')
module.exports = appInfo => {
  const config = {
	view:{
	  root: path.join(appInfo.baseDir, 'app/view'),
	  defaultExtension: '.html',
	  defaultViewEngine: 'nunjucks',
	  mapping: {'.nj':'nunjucks'},
	},
	security: {
		csrf: {
		  enable:false,
		},
	},
  };
  config.keys = appInfo.name + '778477';
  return config;
};

home.js

module.exports = function*() {
  const result = {
    title: 'dumplings',
  };
  yield this.render('index.html', result);
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zerovencommented, Mar 31, 2017

@778477 帮忙同步下文档呗,http://eggjs.org/zh-cn/intro/quickstart.html#模板渲染 这里会掉坑的

0reactions
susanzhang66commented, Oct 14, 2020

楼主怎么解决的??

Read more comments on GitHub >

github_iconTop Results From Across the Web

View Template Rendering - Egg - Eggjs.org
egg-view won't search all directories again for the same template path. mapping and defaultViewEngine. Every view engine has a view engine name ...
Read more >
nunjucks: Error: template not found, Problems with directories
I get the error message that the template was not found. Error: template not found: D:\Development\src\nunjucks\pages\templates\text.njk.
Read more >
Nunjucks
Rich Powerful language with block inheritance, autoescaping, macros, asynchronous control, and more. Heavily inspired by jinja2; Fast & Lean High-performant ...
Read more >
玩egg的一起交流交流啊,怎么感觉人这么少? - CNode技术社区
我按照官网快速开始教程做遇到错误,提示can not find viewEngine 自豪地采用CNodeJS ionic · atian25 6楼•6 年前. @bendise 看看plugin.js 的配置,是不是nunjuck ...
Read more >
eggjs/egg/cn - Gitter
TypeError: Cannot read property 'index' of undefined ... 请教一下,egg配置nunjucks后,报错Can't find ViewEngine "nunjucks".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found