How to Install, Set Up, And Get Started Coding With The Lua Programming Language - On Windows

A List For 2025

By Rob Rockwell

Lua is a compact, high-performance scripting language prized for its small footprint and ease of embedding. Originally created for embedded systems and games, it now powers everything from web servers and IoT devices to popular engines like Roblox and frameworks like LÖVE. With its straightforward syntax and advanced metaprogramming features, Lua excels in scenarios where speed and simplicity are essential.

Whether you’re a seasoned developer embedding a scripting layer into C/C++ applications or a newcomer exploring your first programming language, Lua provides a smooth, accessible experience. In this guide, we’ll cover installing Lua on Windows, setting up your development environment, running your initial scripts, and using LuaRocks to manage libraries and dependencies with ease.

Retro Mainframe Smiling Guy Install Lua

Lua Prerequisites

Before installing Lua on Windows, ensure you have administrator privileges and a working PowerShell or Command Prompt. While no additional software is strictly required, having a package manager like Chocolatey or Scoop can simplify the installation of Lua and related tools.

Optionally, you may install Git for version control and a code editor such as Visual Studio Code or Notepad++ to edit your Lua scripts. If you plan to build native extensions, you’ll also need the Build Tools for Visual Studio (including the C++ compiler), which you can install via the Visual Studio Installer.

Installing Lua

The easiest way to install Lua on Windows is with Chocolatey. Open an elevated PowerShell and run:

choco install lua -y

This command installs the latest Lua interpreter and places the lua executable in your PATH. After installation, verify by opening a new terminal and typing:

lua -v

You should see output similar to Lua 5.4.6, confirming that Lua is ready to use.

Using LuaRocks or Docker for Environment Management

LuaRocks is the de facto package manager for Lua modules. To install it via Chocolatey, run:

choco install luarocks -y

Once installed, you can add libraries with:

luarocks install luasocket

If you prefer containerized environments, you can use Docker to run Lua without installing anything on your host. For example:

docker run -it --rm lua:5.4 lua

This pulls the official Lua image and opens an interactive REPL inside a disposable container.

Verifying Your Installation

After installing Lua, open a new Command Prompt or PowerShell window and check the version to confirm it was installed correctly:

lua -v

You should see output like Lua 5.4.6 (or the version you installed). If you receive an error, ensure that the installation path is included in your system PATH environment variable.

Setting Up LuaRocks for Package Management

LuaRocks is Lua’s official package manager and is used to install and manage modules. Verify that LuaRocks was installed by running:

luarocks --version

To install a module, use a command like:

luarocks install luasocket

This downloads and installs the luasocket module, making it available for your Lua scripts.

Using the Lua Interpreter

The Lua interpreter provides a simple REPL (Read–Eval–Print Loop) for testing code interactively. Start it by typing:

lua

You’ll see the prompt >>, where you can enter Lua commands, for example:

>> print("Hello, Lua on Windows!")

Exit the interpreter by typing os.exit() or pressing Ctrl+Z and then Enter.

Writing Your First Lua Script

Open your text editor (e.g., Visual Studio Code, Notepad++, or Sublime Text) and create a new file named hello.lua. Add the following line of code:

print("Hello, Lua on Windows!")

Save the file, then open Command Prompt or PowerShell, navigate to the directory containing hello.lua, and run:

lua hello.lua

You should see Hello, Lua on Windows! printed to your terminal, confirming that your first Lua script ran successfully.

Configuring Your Editor or IDE

For a better Lua development experience on Windows, use an editor with Lua support. In Visual Studio Code, install the “Lua” extension by sumneko to get syntax highlighting, IntelliSense, and debugging features.

Alternatively, in editors like Sublime Text or Notepad++, install a Lua package or plugin to enable code completion and syntax checking. Make sure your editor is configured to use UTF-8 encoding and that the Lua executable’s path is added to your editor’s runtime settings for proper execution and linting.

Creating a Basic Lua Project

To start a new Lua project, create a directory for your code and initialize it with a main.lua entry point. In Command Prompt or PowerShell, run:

mkdir my_lua_project  
cd my_lua_project  
notepad main.lua

In main.lua, you might begin with a simple module structure, for example:

-- main.lua  
local util = require("util")  
print(util.greet("World"))

Then create a util.lua file alongside it:

-- util.lua  
local M = {}  
function M.greet(name)  
  return "Hello, " .. name .. "!"  
end  
return M

If you’re using LuaRocks, add a rockspec file to declare dependencies so others can install your project with luarocks make.

Next Steps and Learning Resources

Now that you have a basic project structure, explore Lua’s standard libraries and community modules on LuaRocks. Try integrating libraries like luasocket for networking or lpeg for parsing tasks.

For further learning, consult the official Lua 5.4 Reference Manual and the free online book Programming in Lua. Community hubs like the r/lua subreddit and the Lua tag on Stack Overflow are great places to ask questions and share projects.

Enroll in our revolutionary Code Visualization course!