Skip to content

Used to resolve relative Lua paths as well as paths to node_modules.

Notifications You must be signed in to change notification settings

hazzard993/star-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lua Node Resolver

Allows Lua to import relative paths as well as modules from node_modules.

How to install

yarn add lua-star-node   # adds to node_modules/

Import lnr.run in Lua code before using other require calls.

You can use this if Lua's working directory is the same directory containing node_modules.

-- node_modules/
-- main.lua
require("node_modules.lua-star-node.run")

or, if your Lua working directory is inside a folder, use the code below adjusting the dots as needed.

-- node_modules/
-- folder/main.lua
package.path = package.path .. ";../node_modules/?.lua"
require("lua-star-node.run")

How the resolution works

-- File Path:     C:/project/tools/main.lua

require("./foo")  --> C:/project/tools/foo.lua
require("../foo") --> C:/project/foo.lua
require("foo")    --> C:/project/node_modules/module/internal/dir/foo.lua (this is discovered in a rockspec file)

Examples

yarn init -y
yarn add rxi/lurker rxi/lume lua-star-node
echo "require('node_modules.lua-star-node.run')" > main.lua
echo "print(require('lurker'))" >> main.lua
love --console .

About

Used to resolve relative Lua paths as well as paths to node_modules.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published