MoonBit's Package Manager Tutorial
MoonBit's build system seamlessly integrates package management and documentation generation tools, allowing users to easily fetch dependencies from mooncakes.io, access module documentation, and publish new modules.
mooncakes.io is a centralized package management platform. Each module has a corresponding configuration file
moon.mod.json, which is the smallest unit for publishing. Under the module's path, there can be multiple packages, each corresponding to a
moon.pkg.json configuration file. The
.mbt files at the same level as
moon.pkg.json belong to this package.
Before getting started, make sure you have installed moon.
Setup mooncakes.io account
Note: If you don't need to publishing, you can skip this step.
If you don't have an account on mooncakes.io, run
moon register and follow the guide. If you have previously registered an account, you can use
moon login to log in.
When you see the following message, it means you have successfully logged in:
API token saved to ~/.moon/credentials.json
moon update to update the mooncakes.io index.
Setup MoonBit project
Open an existing project or create a new project via
You can browse all available modules on mooncakes.io. Use
moon add to add the dependencies you need, or manually edit the
deps field in
For example, to add the latest version of the