怎么在Mac OS上安装Lua Libevent?

huangapple go评论52阅读模式
英文:

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。

  1. 安装 brew(https://brew.sh/)
  2. 安装 luarocks:

brew install luarocks

  1. 安装你的库:

luarocks install love2d

完成

英文:

Use luarocks.

  1. Install brew ( https://brew.sh/ )
  2. Install luarocks:

brew install luarocks

  1. Install your library:

luarocks install love2d

done

huangapple
  • 本文由 发表于 2023年2月19日 14:11:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498335.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定