support npai version 6(node minimum version v10.20.0).
need lower version check the branch 8.x-10.x or 6.x.
similar as https://github.com/brettlangdon/NodeLua
- nodejs -> lua is async.
- nodejs -> lua in queue, so lua internal is sync.
- all luaState are independent.
- now lua can't call nodejs direct.
- add,linux auto compile luajit.[2018-01-29] http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
- add, cjson compile and auto load. [2018-01-29] https://github.com/openresty/lua-cjson/archive/master.zip
-
win64 need fix.
- support napi. support node 10.20.x-14.x [2021-01-06]
##Installation
npm install node-luajit
// some times maybe need
npm install node-luajit --unsafe-perm
Linux build luajit
git clone https://github.com/LuaJIT/LuaJIT.git
make
sudo make install
and need add one line /usr/local/lib
to /etc/ld.so.conf
file, and run 「/sbin/ldconfig –v」
refresh.
or
ln -s /usr/local/lib/libluajit-5.1.so.2.0.4 /usr/lib
sudo ldconfig
var MyLua = require('node-luajit');
var lua = new MyLua();
lua.doString('print("hello world") return "rettest"',function(err,ret){
console.log('dostring ret:',err,ret)
});
lua.doFile(__dirname+'/test/luatest.lua',function(err,ret){
console.log('doFile ret:',err,ret)
});
lua.callGlobalFunction('print',11,22,function(err,ret){
console.log('callGlobalFunction!!:',err,ret);
})
var lua1 = new MyLua();
var lua2 = new MyLua();
lua1.doString('print("hello world") return "rettest"',function(err,ret){
console.log('lua1 dostring ret:',err,ret)
});
lua2.doString('print("hello world") return "rettest"',function(err,ret){
console.log('lua2 dostring ret:',err,ret)
});
lua1.doFile(__dirname+'/luatest.lua',function(err,ret){
console.log('lua1 doFile ret:',err,ret)
});
lua2.doFile(__dirname+'/luatest.lua',function(err,ret){
console.log('lua2 doFile ret:',err,ret)
});
generate xcode project:
node-gyp configure --debug -- -f xcode
if got TypeError: 'cmp' is an invalid keyword argument for sort()
error.
use python2
instead, such as PYTHON=/usr/bin/python node-gyp configure -- -f xcode
Now you should have a ./build/binding.xcodeproj which you can open.
Configure the executable of the project in Xcode as node and debug away :)