Egg: Can't find ViewEngine "nunjucks",

Created on 29 Mar 2018  ·  14Comments  ·  Source: eggjs/egg

npm i egg-view-ejs --save

npm WARN gentlyRm not removing D:\workdemo\egg-pro\node_modules.bin\mocha.cmd as it wasn't installed by D:\workdemo\egg-pro\node_modules\mocha
npm WARN gentlyRm not removing D:\workdemo\egg-pro\node_modules.bin\mocha as it wasn't installed by D:\workdemo\egg-pro\node_modules\mocha
npm ERR! path D:\workdemo\egg-pro\node_modules\color-convert\node_modules\color-name
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'D:\workdemo\egg-pro\node_modules\color-convert\node_modules\color-name' -> 'D:\workdemo\egg-pro\node_modules\color-convert\node_modules\color-name'
npm ERR! enoent This is related to npm not being able to find a file.

Most helpful comment

将 plugin.js 修改成如下,就可以使用了。

module.exports = {
nunjucks : {
enable: true,
package: 'egg-view-nunjucks',
}
};

All 14 comments

你的 egg 版本是不是 0.x 的?

升级之后, plugin.js 里面的 exports.view 要改为 exports.ejs

装了 ejs 配了 nunjucks

安装 nunjucks 也报错下面是我的版本

name": "egg-pro",
"version": "1.0.0",
"description": "",
"private": true,
"dependencies": {
"egg": "^2.2.1",
"egg-scripts": "^2.5.0"
},
"devDependencies": {
"autod": "^3.0.1",
"autod-egg": "^1.0.0",
"egg-bin": "^4.3.5",
"egg-ci": "^1.8.0",
"egg-mock": "^3.14.0",
"eslint": "^4.11.0",
"eslint-config-egg": "^6.0.0",
"webstorm-disable-index": "^1.2.0"
},
"engines": {
"node": ">=8.9.0"

npm i egg-view-nunjucks --save
npm WARN gentlyRm not removing D:\workdemo\egg-pro\node_modules.bin\mocha.cmd as it wasn't installed by D:\workdemo\egg-pro\[email protected]@mocha
npm WARN gentlyRm not removing D:\workdemo\egg-pro\node_modules.bin\mocha as it wasn't installed by D:\workdemo\egg-pro\[email protected]@mocha

贴 plugin.js 。。。 然后看看文档

不安装配了找不到, 已安装就报错。。。
'use strict';

// had enabled by egg
// exports.static = true;
exports.nunjucks = {
enable: true,
package: 'egg-view-nunjucks'
};

'use strict';

module.exports = appInfo => {
const path = require('path');
const config = exports = {};

// use for cookie sign key, should change to your own and keep security
config.keys = appInfo.name + '_1522294085159_2600';

// add your config here
config.middleware = [];
config.view = {
defaultViewEngine: 'nunjucks',
mapping: {
'.tpl': 'nunjucks',
},
root: [
path.join(appInfo.baseDir, 'app/view'),
path.join(appInfo.baseDir, 'path/to/another'),
].join(',')
};

return config;
};

直接提交一个最小可复现代码库

安装文档的走的, 走不下去了。。。

提交到你的 github。。。

什么情况啊?搞定了吗? 我这安装egg-view-nunjucks的时候也是安装不了。

同问,找不到这个包

plugin.js,不要 exports.view =

将 plugin.js 修改成如下,就可以使用了。

module.exports = {
nunjucks : {
enable: true,
package: 'egg-view-nunjucks',
}
};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aka99 picture aka99  ·  3Comments

dizhifeng picture dizhifeng  ·  3Comments

bupafengyu picture bupafengyu  ·  3Comments

wujianling picture wujianling  ·  3Comments

skyyangpeng picture skyyangpeng  ·  3Comments