Lapis:无法加载`etlua`文件

时间:2014-11-10 09:53:14

标签: nginx lua

我有hello.etlua @ /usr/local/share/lua/5.1/lapis/views/ etlua已经由luarocks安装。 OS Debian。 这段代码

local lapis = require("lapis")

local app = lapis.Application()
app:enable("etlua")

app:match("/", function()
return { render: "hello" }
end)

return app

给了我这样的错误: 错误

  

/usr/local/share/lua/5.1/lapis/application.lua:121:模块   'views.index'找不到:没有字段package.preload ['views.index']可以   不加载etlua文件没有文件'./lua/views/index.lua'没有文件   '/etc/nginx/lua/views/index.lua'no file'./views/index.lua'no file   '/usr/local/share/luajit-2.1.0-alpha/views/index.lua'no file   '/usr/local/share/lua/5.1/views/index.lua'没有档案   '/usr/local/share/lua/5.1/views/index/init.lua'no file   './views/index.so'no file'/usr/local/lib/lua/5.1/views/index.so'no   file'/usr/local/lib/lua/5.1/loadall.so'no file'./views.so'no file   '/usr/local/lib/lua/5.1/views.so'没有文件   '/usr/local/lib/lua/5.1/loadall.so'Trapbackback

     

堆栈追溯:[C]:在函数'require'中   /usr/local/share/lua/5.1/lapis/application.lua:121:在功能上   'render'/usr/local/share/lua/5.1/lapis/application.lua:406:in   函数[C]:在函数'xpcall'中   /usr/local/share/lua/5.1/lapis/application.lua:400:在功能上   'dispatch'/usr/local/share/lua/5.1/lapis/nginx.lua:181:在功能上   'serve'content_by_lua:2:in function

常用模板正常运行:

local template = etlua.compile([[
Hello <%= name %>,
Here are your items:
<% for i, item in pairs(items) do %>

<%= item -%> <% end %> ]])
print(template({
name = "leafo",
items = { "Shoe", "Reflector", "Scarf" }
}))

我收到了日志文件中的数据。 它是什么?我做错了什么?这是一个错误吗?

2 个答案:

答案 0 :(得分:3)

package.path = '/usr/local/share/lua/5.1/lapis/?.lua;' .. package.path
local lapis = require("lapis")

答案 1 :(得分:0)

解决方案是错误的观点。我把文件放在/usr/local/share/lua/5.1/lapis/views。但这是不正确的。正确的位置是/usr/local/share/lua/5.1/views