Skip to content

dannyfritz/node-resolve-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-resolve-lua

npm npm

Implements node's require.resolve module resolution pattern for Lua.

This allows you to install Lua packages from npm and require them like normal modules.

All of the features of npm will come with using this pattern.

  • Semantic Versioning of modules
  • Modules installed locally, not globally
  • Manage installed modules in a package.json file
  • npm scripts
  • Tons more

Usage

npm uses this pattern when it installs modules. So let's use npm! installing npm

In your project directory, we need to install node-resolve-lua:

$ npm install node-resolve-lua
--Only needs to be done once
require("./node_modules/node-resolve-lua/node-resolve")

And that's it! You're ready to include modules from npm now.

Example Usage

If we wanted to use a module from npm such as luadash, we would do this:

$ npm install luadash
local __ = require("luadash")

function double (value)
  return value * 2
end

__.map(double, {1, 2, 3}) -- => {2, 4, 6}

About

Implement the node-resolve module resolution pattern in Lua.

Resources

Stars

Watchers

Forks

Languages