我正在将 node.js 服务器从运行 Mac 的笔记本电脑上的开发移动到运行 Ubuntu 12.04 的托管服务器上的生产。
进行测试以确保一切正常,我在 Ubuntu 控制台中收到以下错误:
Debug: hapi, internal, implementation, error
Error: View file not found: /var/local/app/pages/templates/appLogin.html
如果我在控制台中输入cd /var/local/app/pages/templates/
然后ls
,appLogin.html
就会出现。
在我的 Mac 上,一切正常。
这就是我使用 Hapi.js 设置 EJS 的方式:
var Ejs = require('ejs');
Ejs.registerHelper = function (name, fn) {
engine.module.filters[name] = fn;
};
var serverOptions= {
cors: true,
files: { relativeTo: __dirname },
views: {
engines: {
html: {module: Ejs} },
path: __dirname + '/pages/templates'
}
};
var server = Hapi.createServer('localhost', '8000', serverOptions );
为什么有区别?我在这里想念什么?