英文:
how to install lua liberec on mac os?
问题
如何在Mac OS上安装Lua的liberec?
我不知道如何做这个
main.lua
local luajson = require "lunajson"
local file = io.open("main.json", "r")
local data = file:read("*all")
file:close()
local tbl = luajson.decode(data)
print(tbl["name"])
main.json
{
"name": "Timofey"
}
终端:
lua: main.lua:1: module 'lunajson' not found:
no field package.preload['lunajson']
no file '/usr/local/share/lua/5.4/lunajson.lua'
no file '/usr/local/share/lua/5.4/lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.lua'
no file '/usr/local/lib/lua/5.4/lunajson/init.lua'
no file './lunajson.lua'
no file './lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.so'
no file '/usr/local/lib/lua/5.4/loadall.so'
no file './lunajson.so'
stack traceback:
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in ?
我尝试过重新启动Mac,但仍然出现错误。
英文:
how to install lua liberec on mac os?
I do not know how to do this
main.lua
local luajson = require "lunajson"
local file = io.open("main.json", "r")
local data = file:read("*all")
file:close()
local tbl = luajson.decode(data)
print(tbl["name"])
main.json
{
"name": "Timofey"
}
terminal:
lua: main.lua:1: module 'lunajson' not found:
no field package.preload['lunajson']
no file '/usr/local/share/lua/5.4/lunajson.lua'
no file '/usr/local/share/lua/5.4/lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.lua'
no file '/usr/local/lib/lua/5.4/lunajson/init.lua'
no file './lunajson.lua'
no file './lunajson/init.lua'
no file '/usr/local/lib/lua/5.4/lunajson.so'
no file '/usr/local/lib/lua/5.4/loadall.so'
no file './lunajson.so'
stack traceback:
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in ?
I tried restarting the mac, but it still gives an error
答案1
得分: 1
使用 luarocks。
- 安装 brew(https://brew.sh/)
- 安装 luarocks:
brew install luarocks
- 安装你的库:
luarocks install love2d
完成
英文:
Use luarocks.
- Install brew ( https://brew.sh/ )
- Install luarocks:
brew install luarocks
- Install your library:
luarocks install love2d
done
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论